ted.martin
Registered User.
- Local time
- Today, 12:18
- Joined
- Sep 24, 2004
- Messages
- 743
I have an Append query that I need to run successively several times BUT with a field name changing each time.
My code is:
Dim strSQL As String
strSQL = "INSERT INTO MediaMail ( [e-mail1] )" & _
"SELECT Contacts.[e-mail1]" & _
"FROM [Contacts]" & _
"WHERE Contacts.[Media1]= -1;"
DoCmd.RunSQL strSQL
The only part in the SQL that needs to change is [Media1] as the next time it is called the field is Media2, then Media3 etc.
How can I use VBA code to change the name of this field in the SQL statement?
Thanks
Ted
My code is:
Dim strSQL As String
strSQL = "INSERT INTO MediaMail ( [e-mail1] )" & _
"SELECT Contacts.[e-mail1]" & _
"FROM [Contacts]" & _
"WHERE Contacts.[Media1]= -1;"
DoCmd.RunSQL strSQL
The only part in the SQL that needs to change is [Media1] as the next time it is called the field is Media2, then Media3 etc.
How can I use VBA code to change the name of this field in the SQL statement?
Thanks
Ted