I’ve been writing some pretty long SQL queries in notepad and then pasting them into my VBA code as-is and then formatting the multi-line string correctly each line at a time. For example…
In my text editor, the query looks like this.
SELECT
a,
b,
c,
...,
n
FROM
table1,
table2,
...,
tableN
WHERE
etc
Then pasting this into the VBA editor and manually adding sqlStr = sqlStr & ” …. “ to every line.
sqlStr = " SELECT "
sqlStr = sqlStr & " a,"
sqlStr = sqlStr & " b,"
sqlStr = sqlStr & " c,"
sqlStr = sqlStr & " ...,"
sqlStr = sqlStr & " n"
sqlStr = sqlStr & " FROM"
sqlStr = sqlStr & " table1,"
sqlStr = sqlStr & " table2,"
sqlStr = sqlStr & " ...,"
sqlStr = sqlStr & " tableN"
sqlStr = sqlStr & " WHERE"
sqlStr = sqlStr & " etc"
Does anyone know of a tool that will let me automatically wrap the VBA string stuff around my query (instead of adding it manually)? I imagine there’s a web site somewhere for that, but I can’t find it.
I could rig up something in Vi, but I can’t guarantee that I’ll be doing this on a computer that I’ll have rights to install Vi on.
Any help appreciated! Thanks.
You might want to look at SQLinForm. Among other formats, it allows you to format SQL for use in VB/VBA