Hello.
I am writing some VBA so it can grab the information i require from the database and put it into excel. No problem really, except for one apparent simple hurdle. One of my SQL statements as shown below, is far to large to fit onto one line, thus it tells me the syntax is incorrect. I have tried to break the line into multiple lines by using.
"+
_
Unfortunately it still tells me the syntax is incorrect. Any idea's? Thanks in advance
obj.Execute ("select csbgrp, csbwhseno, csbyear, csbtype, csbbudget1, 1 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget2, 2 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget3, 3 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget4, 4 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget5, 5 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget6, 6 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget7, 7 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget8, 8 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget9, 9 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget10, 10 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget11, 11 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 union all select csbgrp, csbwhseno, csbyear, csbtype, csbbudget12, 12 period from salesbudget where csbyear = " & chr(34) & "2007" & chr(34) & " and csbwhseno = " & chr(34) & "ELT" & chr(34) & " group by 1,2,3,4,5 into temp a4;")
Start Free Trial