PDA

View Full Version : Solved: SQL error



lifeson
01-31-2008, 05:35 AM
I am having trouble ( as usual :bug: ) with the following

I am using excel to extract records from an access database and have got stuck with the following

Src = "SELECT TblAddress.AddressType, _
TblAddress.LeadNumber, _
TblAddress.Title, _
TblAddress.LastName, _
TblAddress.AddressLine1, _
TblAddress.PostCodeIn, _
TblAddress.PostCodeOut FROM TblAddress _
WHERE (((TblAddress.AddressType) = "I")) _
WITH OWNERACCESS OPTION;"

I am getting a sytax error :doh:
I don't think I've got the line wrapping right and when I put it all on one line, (((TblAddress.AddressType) = "I")) causes a problem aswell

Any help greatly appreciated.

rory
01-31-2008, 06:01 AM
Try:
Src = "SELECT TblAddress.AddressType, " & _
"TblAddress.LeadNumber, " & _
"TblAddress.Title, " & _
"TblAddress.LastName, " & _
"TblAddress.AddressLine1, " & _
"TblAddress.PostCodeIn, " & _
"TblAddress.PostCodeOut FROM TblAddress " & _
"WHERE (((TblAddress.AddressType) = 'I')) " & _
"With OWNERACCESS OPTION;"

lifeson
01-31-2008, 06:52 AM
Thanks Rory
I tried the single quote rather than double quotes which solved the problem with the variable but I couldn't solve the multi line
Thanks

rory
01-31-2008, 07:38 AM
Did you put in the '&' at the end of each line too? Works fine for me.

lifeson
01-31-2008, 07:47 AM
Did you put in the '&' at the end of each line too? Works fine for me.

Sorry
Yes it does work :clap:
What I meant was, yes, you gave me the solution for the multiline which I couldn't work out, but I had worked out the single quote marks around the variable before you replied

Thanks again