whats wrong with this code ?

sconly

Registered User.
Local time
Today, 22:26
Joined
Oct 8, 2002
Messages
56
can anybody find a not too deliberate mistake in the following code:

sAppend = "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"""
 
You are not putting any spaces between field names and the SQL commands when you use run on lines.

i.e

Subcons.eMailFROM Subcons

which should be:

Subcons.eMail FROM Subcons
 
"WHERE Subcons.Pick =""S""" won't work because you don't have Subcons.Pick in your SELECT statement.
 
naygl said:
"WHERE Subcons.Pick =""S""" won't work because you don't have Subcons.Pick in your SELECT statement.

That's irrelevant.
 
You don't need to include it in your result set, its just criteria - exactly the same as when you don't display the criteria column in the QBE grid by unticking the box under it.
 
Is that an Access thing? I was sure that wouldn't work on TOAD.
 
My 2 cents ...

"FROM Subcons" & _
" WHERE Subcons.Pick ='S'"

put a space before your WHERE and use single quotes around the S.

Sorry naygl, the boys are right. You do not have to have a field be a part of the selection in order to specify criteria on the field. That is not an Access thing.
 

Users who are viewing this thread

Back
Top Bottom