I have a very long SQL statement in a module that needs to be broken into several lines for readability. I've added _ at the point where I wish the line to break, but I then get a compile error . . Expected: End of Statement (with 'WHERE' highlighted. The code runs fine on one line, so it's my syntax in breaking up the line.
The code that returns the error is (two lines, broken before the 'WHERE'):
strSQL = "SELECT tblMain.ID, tblMain.FileNumber, tblMain.DateIn, tblMain.EnteredBy, tblMain.Barcode1, tblMain.Barcode2, tblMain.Barcode3, tblMain.Barcode4, tblMain.Barcode5, tblMain.Barcode6, tblMain.Barcode7, tblMain.Barcode8, tblMain.Barcode9, tblMain.Barcode10, tblMain.EvidenceReturned, tblMain.Location1, tblMain.Location2, tblMain.Location3, tblMain.Location4, tblMain.Location5, tblMain.RemovedBy, tblMain.DateOut, tblMain.Comments, tblMain.Description, tblMain.ReleasedTo FROM tblMain" _
WHERE (((tblMain.EvidenceReturned)=False) AND ((tblMain.Location1) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location2) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location3) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location4) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location5) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria]))"
Thanks! - - - -
Bryan
The code that returns the error is (two lines, broken before the 'WHERE'):
strSQL = "SELECT tblMain.ID, tblMain.FileNumber, tblMain.DateIn, tblMain.EnteredBy, tblMain.Barcode1, tblMain.Barcode2, tblMain.Barcode3, tblMain.Barcode4, tblMain.Barcode5, tblMain.Barcode6, tblMain.Barcode7, tblMain.Barcode8, tblMain.Barcode9, tblMain.Barcode10, tblMain.EvidenceReturned, tblMain.Location1, tblMain.Location2, tblMain.Location3, tblMain.Location4, tblMain.Location5, tblMain.RemovedBy, tblMain.DateOut, tblMain.Comments, tblMain.Description, tblMain.ReleasedTo FROM tblMain" _
WHERE (((tblMain.EvidenceReturned)=False) AND ((tblMain.Location1) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location2) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location3) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location4) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria])) OR (((tblMain.Location5) Like [Forms]![frmCurrentLocationSearchCriteria]![SearchCriteria]))"
Thanks! - - - -
Bryan