code help !!!

sconly

Registered User.
Local time
Today, 01:36
Joined
Oct 8, 2002
Messages
56
starter for 10:

whats wrong with the code below. i get the following error.

Syntac error in query. Incomplete query clause.


DoCmd.RunSQL "INSERT INTO 'TableName' ( TradeCode, Trade, CompanyName, Town, County, PostCode, Fax, Contact, Mobile, eMail )" & _
"SELECT Subcons.TradeCode, Subcons.Trade, Subcons.CompanyName, Subcons.Town, Subcons.County, Subcons.PostCode, Subcons.Fax, Subcons.Contact, Subcons.Mobile, Subcons.eMail" & _
"FROM Subcons" & _
"WHERE Subcons.Pick =""'S'"""
 
If you aren't building the SQL dynamically, there is a disadvantage to building it in code in the first place, saved queries run faster. I'd recommend building the query in a QBF grid and using Docmd.OpenQuery instead.

The first error I see in the SQL is that there is no space before the keyword SELECT. You may also need to enclose single quotations in double quotation marks to get the SQL string to accept them. when doing something like this I always use a message box to view the SQL before it is processed to check for errors.
 

Users who are viewing this thread

Back
Top Bottom