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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I Wrap Long Lines of SQL?? 4

Status
Not open for further replies.

DCBBB

IS-IT--Management
Aug 22, 2001
33
US
I can't seem to remember how to wrap a long sql statement. I am using DoCmd.RunSQL and sql cut and pasted from a query, but the line is too long. I seem to remember a way to effectively wrap this with underscores and ampersands, but it's not working. Help!

 
just put an underscore where you want to break the line. No & neccessary.
 
just put an underscore where you want to break the line. No & neccessary. I don't think you can do it in the middle of a string or command.
 
To do it in the middle of a string use both ampersands and underscores like so:

DoCmd.RunSQL "SELECT * FROM tblGenericName " & _
"WHERE intA > intB"

Close off the first line with end quotes, use the ampersand to concantenate the strings and the underscore continues the same line of code...

Hope this helps,
Kyle ::)
 
Thanks for your help, Stickarm and Kyle. I got it working - I knew someone would know how to do this.
Doug
 
Stickarm,
here you go

strSQL = "select FIeld1, FIeld2, FIeld3,Field4 from SomeTable "
strSQL = strSQL & "where FIeld1 like '%" & TheCriteria & "%' and "
strSQL = strSQL & "FIeld2 like '%" & SecondCriteria & "%' and "
strSQL = strSQL & "FIeld3 like '%" & thirdCriteria & "%' and "
strSQL = strSQL & "Field4 = WhateverCriteria "
strSQL = strSQL & " order by [SomeTable].FIeld1,[SomeTable].FIeld2, [SomeTable].FIeld3, [SomeTable].FIeld4"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top