Syntax error help

M

Mike Green

Hi All
Please could someone let me know the correct syntax for adding a text string
requirement for the sql statement below. Or am I going about this the wrong
way? This is a button on a form so that the user can click it to show all
the records with the stated.
Thanks in advance.

Mike

StrSQLAllveh = "SELECT TblJobCard.FdJobCardID, TblJobCardJobs.FdJobType," &
_
"TblJobCardJobs.FdJobCardJobDescription, TblJobCard.FdJobCardCloseDate,
TblJobCard.FdVRN, " & _
"TblJobCard.FdJCNumberText, TblJobCard.FdCustomerID, TblJobCard.FdMotin,
TblJobCard.FdMOTinDate " & _
"FROM TblJobCardJobs RIGHT JOIN TblJobCard ON TblJobCardJobs.FdJobCardID
= TblJobCard.FdJobCardID " & _
"WHERE (((TblJobCardJobs.FdJobType)= " & "Carry Out Annual MOT" & " )" &
_
"AND ((TblJobCardJobs.FdJobCardJobDescription)= " & "MOT" & ") AND
((TblJobCard.FdJobCardCloseDate)<Date()-330));"
 
G

Guest

If it's a fixed string you are trying to set then try using a single quote
before and after the string

StrSQLAllveh = "SELECT TblJobCard.FdJobCardID, TblJobCardJobs.FdJobType," & _
"TblJobCardJobs.FdJobCardJobDescription, TblJobCard.FdJobCardCloseDate,
TblJobCard.FdVRN, " & _
"TblJobCard.FdJCNumberText, TblJobCard.FdCustomerID, TblJobCard.FdMotin,
TblJobCard.FdMOTinDate " & _
"FROM TblJobCardJobs RIGHT JOIN TblJobCard ON TblJobCardJobs.FdJobCardID
= TblJobCard.FdJobCardID " & _
"WHERE (((TblJobCardJobs.FdJobType)= 'Carry Out Annual MOT' )" & _
"AND ((TblJobCardJobs.FdJobCardJobDescription)= 'MOT') AND
((TblJobCard.FdJobCardCloseDate)<Date()-330));"
 
M

Mike Green

Thanks for that, it works.


Ofer Cohen said:
If it's a fixed string you are trying to set then try using a single quote
before and after the string

StrSQLAllveh = "SELECT TblJobCard.FdJobCardID, TblJobCardJobs.FdJobType,"
& _
"TblJobCardJobs.FdJobCardJobDescription, TblJobCard.FdJobCardCloseDate,
TblJobCard.FdVRN, " & _
"TblJobCard.FdJCNumberText, TblJobCard.FdCustomerID,
TblJobCard.FdMotin,
TblJobCard.FdMOTinDate " & _
"FROM TblJobCardJobs RIGHT JOIN TblJobCard ON
TblJobCardJobs.FdJobCardID
= TblJobCard.FdJobCardID " & _
"WHERE (((TblJobCardJobs.FdJobType)= 'Carry Out Annual MOT' )" & _
"AND ((TblJobCardJobs.FdJobCardJobDescription)= 'MOT') AND
((TblJobCard.FdJobCardCloseDate)<Date()-330));"
 

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

Similar Threads


Top