Advertisement

06.25.2007 at 02:40PM PDT, ID: 22656976
[x]
Attachment Details

VBA - SQL statement over multiple lines

Asked by SaxonNZ in Informix Database, Visual Basic Programming

Tags: multiple, vba, sql, lines, statement

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
 
Loading Advertisement...
 
[+][-]06.25.2007 at 02:47PM PDT, ID: 19359516

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 03:15PM PDT, ID: 19359664

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Informix Database, Visual Basic Programming
Tags: multiple, vba, sql, lines, statement
Sign Up Now!
Solution Provided By: aikimark
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.25.2007 at 05:50PM PDT, ID: 19360300

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 08:26PM PDT, ID: 19360788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32