String spanning multiple lines

  • Thread starter Thread starter Guest
  • Start date Start date
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).
 
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"
 
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.
 
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;"
 
Back
Top