×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How do I Wrap Long Lines of SQL??
4

How do I Wrap Long Lines of SQL??

How do I Wrap Long Lines of SQL??

(OP)
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!

RE: How do I Wrap Long Lines of SQL??

just put an underscore where you want to break the line. No & neccessary.

RE: How do I Wrap Long Lines of SQL??

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.

RE: How do I Wrap Long Lines of SQL??

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

RE: How do I Wrap Long Lines of SQL??

(OP)
Thanks for your help, Stickarm and Kyle.  I got it working  - I knew someone would know how to do this.
Doug

RE: How do I Wrap Long Lines of SQL??

2
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"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close