query input must contain atleast one table or query

G

Guest

I am in the process of writing a procedure to copy several tables from a
master database that we maintain in our home office to separate databases
that we send out to our subsidiaries. There are two separate destinations
(directories) for the tables. I have created a form to get the destination
deisred from the database owner.
IN VBA I reference the field on the form that contains the destination path
and store that path to a string variable "strDestination"
Next, I used the Query Builder to create the queries and copied them into my
VBA procedure as follows:

Dim strSQL As String
Dim strDestination As String
strDestination = Forms!f_Export!Product

't_Contacts
strSQL = "SELECT ContactID,ContactNUM, BusinessUnitID,Name,
Telephone,E_Mail,Lead,"
strSQL = strSQL & "Manager,Liaison,CoordLead,LastUpdated"
strSQL = strSQL & " INTO t_Contact IN " & strDestination & " FROM t_Contact;"
DoCmd.RunSQL strSQL

On executing the code, I get the message "Query input must contain at least
one tble or query. "
Any hint as to what I am doing incorrectly?
Thanks
 
D

Douglas J. Steele

Are there spaces in the content of strDestination? If so, you'll need to put
quotes around it:

strSQL = "SELECT ContactID,ContactNUM, BusinessUnitID,Name,
Telephone,E_Mail,Lead,"
strSQL = strSQL & "Manager,Liaison,CoordLead,LastUpdated"
strSQL = strSQL & " INTO t_Contact IN " & Chr(34) & strDestination &
Chr(34) & " FROM t_Contact"
 
G

Guest

Thank you!

Douglas J. Steele said:
Are there spaces in the content of strDestination? If so, you'll need to put
quotes around it:

strSQL = "SELECT ContactID,ContactNUM, BusinessUnitID,Name,
Telephone,E_Mail,Lead,"
strSQL = strSQL & "Manager,Liaison,CoordLead,LastUpdated"
strSQL = strSQL & " INTO t_Contact IN " & Chr(34) & strDestination &
Chr(34) & " FROM t_Contact"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top