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).
Brian - 24 Sep 2005 02:50 GMT
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"
> 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).
RuralGuy - 24 Sep 2005 03:19 GMT
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.
David C. Holley - 24 Sep 2005 04:04 GMT
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;"
> 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).