Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very long SQL statement - line continuation

Status
Not open for further replies.

DanAuber

IS-IT--Management
Apr 28, 2000
255
FR
Hi there,

I have a HUGE sql statement which I'm entering into a Module as follows:

docmd.runsql ("Select etc etc etc;")

The statement will not fit on one line so I'm trying to do the following:

docmd.runsql ("Select etc etc _
etc etc etc;")


However Access will not accept it

Can anyone help me get over this ?

Thanks in advance

 

Dim strSQL AS String
'Building one line at a time
strSQL = "SELECT "
strSQL = strSQL & "Field_1, "
strSQL = strSQL & "Field_2, "
...
strSQL = strSQL & "Field_N, "
'Building with line continuation
strSQL = strSQL & "FROM yourTableNameHere " & _
"WHERE Field_1 = 'LaLaLa'"
'Just don't forget any space needed between continuations
 
You may get a message "too many line continuation characters" with a very long string. If you do, use smaller pieces.

strSQL= "Blah _"
strSQL=strSQL & "More Blah _
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top