I'm stuck again.
Here's what i'm trying to do:
I have a table with adresses with multiple fields (ia emailadress and a check box)
I have a table with emailgroups with two fields: groupname and groupmembers. The field groupmembers is basically a string of emailadresses seperated by a semicolon.
In a form with the table with adresses as a source, I'm able to check and uncheck adresses.
Now what I wish to do, is build an email group from the checked adresses and add it as a new record to the table with emailgroups, asking the user for a name for the new group.
I put a button on the form to do that.
Until now, I have this code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strName As String
Dim strQuery As String
Dim rs2 As DAO.Recordset
Set db = CurrentDb
Set rs2 = db.OpenRecordset("SELECT Name From MSysObjects WHERE Name = 'Query2';")
If rs2.RecordCount = 1 Then
DoCmd.DeleteObject acQuery, "Query2"
End If
rs2.Close
strName = "Query2"
strQuery = "SELECT TableAdress.Checked, TableAdress.EmailAdres FROM Query1 WHERE (((TableAdress.Checked)=Yes) AND ((Table.EmailAdres) Is Not Null));"
Set qdf = db.CreateQueryDef(strName, strQuery)
qdf.Close
This creates a query with the required emailadresses.
Any suggestions on how to proceed from here?
I figure I have to build a string from the records of Query2 and then run some kind of append query, but that is way over my head.
Does anyone have any suggestions?
Thanks in advance!
Here's what i'm trying to do:
I have a table with adresses with multiple fields (ia emailadress and a check box)
I have a table with emailgroups with two fields: groupname and groupmembers. The field groupmembers is basically a string of emailadresses seperated by a semicolon.
In a form with the table with adresses as a source, I'm able to check and uncheck adresses.
Now what I wish to do, is build an email group from the checked adresses and add it as a new record to the table with emailgroups, asking the user for a name for the new group.
I put a button on the form to do that.
Until now, I have this code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strName As String
Dim strQuery As String
Dim rs2 As DAO.Recordset
Set db = CurrentDb
Set rs2 = db.OpenRecordset("SELECT Name From MSysObjects WHERE Name = 'Query2';")
If rs2.RecordCount = 1 Then
DoCmd.DeleteObject acQuery, "Query2"
End If
rs2.Close
strName = "Query2"
strQuery = "SELECT TableAdress.Checked, TableAdress.EmailAdres FROM Query1 WHERE (((TableAdress.Checked)=Yes) AND ((Table.EmailAdres) Is Not Null));"
Set qdf = db.CreateQueryDef(strName, strQuery)
qdf.Close
This creates a query with the required emailadresses.
Any suggestions on how to proceed from here?
I figure I have to build a string from the records of Query2 and then run some kind of append query, but that is way over my head.
Does anyone have any suggestions?
Thanks in advance!