You can supply the target table name at runtime if you execute an append
query string instead of running a saved query.
1. Mock up a query that does what you need, using a dummy table name.
2. Switch it to SQL View (View menu, in query design.)
3. Copy the entire SQL statement to clipboard.
4. Paste it into VBA code, as a single line, or by closing quotes and adding
line continuation characters.
5. Execute the string.
You will end up with something like this:
Function RunMyAppendQuery(strTable As String)
Dim strSql As String
strSql = "INSERT INTO " & strTable & " ( Field1, Field2 ) " & _
"SELECT Surname, FirstName FROM tblClient;"
dbEngine(0)(0).Execute strSql, dbFailOnError
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
message
news:
[email protected]...