String spanning multiple lines

G

Guest

I know this is probably a dumb question with a simple answer, but how do I
get VBA to recognize a long string (over the 1024-character limit for a line
in VBA) as a single string (e.g. when concatenating a long SQL statement).
 
G

Guest

Never mind. I knew it had to do with the underscore and ampersand. I just
didn't get the right combination of the quotes and the space before the
underscore with the ampersand and qutoes on the next line.

ABC = "BlahBlahBlah" _
& "BlahBlahBlah" _
& "ad infinitum"
 
R

RuralGuy

MyString = ".........................................." & _
"------------------------------------------" & _

etc.

The concatenation sequence is a space, the "&" and then another space and the
underscore.


I know this is probably a dumb question with a simple answer, but how do I
get VBA to recognize a long string (over the 1024-character limit for a line
in VBA) as a single string (e.g. when concatenating a long SQL statement).

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
D

David C. Holley

Use the line continuation characater which you probably want me to tell
you is the underscore as in ...

If a = 1 AND b = 1 AND c = 1 _
AND BillGates = "IDIOT" Then

Another trick which I'm found of is to break up the SQL statement in to
lines using natural line break - end of a field, between keywords etc.
to make reading it easier as in

strSQL = "SELECT lngTransportId, lngOrgKey, lngDestKey, _
dteDate, dteTimeScheduled _
FROM tblTransports _
WHERE lngTransportId = 1505 AND lngOrgKey = 43 AND lngDestKey = 54 _
ORDER BY lngTransportID;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top