underscore=line continuation?

  • Thread starter Thread starter placek
  • Start date Start date
P

placek

hello

in a book i'm reading it says the underscore character is
used in vba as a line continuation character. However,
when i write the following SQL statement the first field
on the third line is highlighted and an error appears
stating 'compile error: expected: list seperator or )'.
Why is this?

Set mrec = mdb.OpenRecordset("SELECT
tblLoanRelation.lngAcquisitionNumbercnt, _
tblBookRelation.strISBN, tblBookRelation.strTitle,
tblBookRelation.strAuthor, _
tblLoanRelation.dtmDateReserved,
tblLoanRelation.dtmDateBorrowed FROM tblloanrelation, _
tblacquisitionrelation, tblbookrelation WHERE _
tblloanrelation.lngacquisitionnumbercnt=tblacquisitionrelat
ion.lngacquisitionnumbercnt _
AND tblacquisitionrelation.strisbn=tblbookrelation.strisbn
_
AND tblloanrelation.lngBorrowerNumbercnt=" &
mvarlngNumber, dbOpenDynaset)
 
When you are building a long text string, such as the SQL statement that
you're showing, you must "end" and "re-begin" the string on each line, and
concatenate each line together.

Set mrec = mdb.OpenRecordset("SELECT " & _
"tblLoanRelation.lngAcquisitionNumbercnt, " & _
"tblBookRelation.strISBN, tblBookRelation.strTitle, " & _
"tblBookRelation.strAuthor, " & _
"tblLoanRelation.dtmDateReserved, " & _
"tblLoanRelation.dtmDateBorrowed FROM tblloanrelation, " & _
"tblacquisitionrelation, tblbookrelation WHERE " & _
"tblloanrelation.lngacquisitionnumbercnt=" & _
"tblacquisitionrelation.lngacquisitionnumbercnt " & _
"AND tblacquisitionrelation.strisbn=tblbookrelation.strisbn " & _
"AND tblloanrelation.lngBorrowerNumbercnt=" & _
mvarlngNumber, dbOpenDynaset)
 
thanks ken
-----Original Message-----
When you are building a long text string, such as the SQL statement that
you're showing, you must "end" and "re-begin" the string on each line, and
concatenate each line together.

Set mrec = mdb.OpenRecordset("SELECT " & _
"tblLoanRelation.lngAcquisitionNumbercnt, " & _
"tblBookRelation.strISBN, tblBookRelation.strTitle, " & _
"tblBookRelation.strAuthor, " & _
"tblLoanRelation.dtmDateReserved, " & _
"tblLoanRelation.dtmDateBorrowed FROM tblloanrelation, " & _
"tblacquisitionrelation, tblbookrelation WHERE " & _
"tblloanrelation.lngacquisitionnumbercnt=" & _
"tblacquisitionrelation.lngacquisitionnumbercnt " & _
"AND
tblacquisitionrelation.strisbn=tblbookrelation.strisbn " &
_
 
Back
Top