i would like to type the following line in Excel 2003 macro but its too long how do i correct it (divide it) that excel macro will except it?

Set comm.ActiveConnection = conn
    comm.CommandText = _
"select cutdetail.cutno, cutdetail.style, cutdetail.color, cutdetail.qty, cutdetail.qty1, cutdetail.qty2, cutdetail.qty3, cutdetail.qty4, cutdetail.qty5, cutdetail.qty6, cutdetail.qty7, cutdetail.qty8, cutdetail.qty9, cutdetail.qty10, cutdetail.qty11, cutdetail.qty12, division.size1, division.size2, division.size3, division.size4, division.size5, division.size6, division.size7, division.size8, division.size9, division.size10, division.size11, division.size12 from cutdetail, ivtf, division where cutdetail.cutno = '9702204' and cutdetail.style = ivtf.code and cutdetail.color = ivtf.color and ivtf.division = division.code  group by cutdetail.cutno, cutdetail.style, cutdetail.color , cutdetail.qty1, cutdetail.qty2, cutdetail.qty3, cutdetail.qty4, cutdetail.qty5, cutdetail.qty6, cutdetail.qty7, cutdetail.qty8, cutdetail.qty9, cutdetail.qty10, cutdetail.qty11, cutdetail.qty12 , cutdetail.qty, division.size1, division.size2, division.size3, division.size4, division.size5, division.size6, division.size7, division.size8, division.size9, division.size10, division.size11, division.size12"


the select stetment its too long to excel macro how do i string it or divided it to two part that excel macro will accept it?
gvilbisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rory ArchibaldCommented:
You can use line continuation characters like this:

comm.CommandText = _
"select cutdetail.cutno, cutdetail.style, cutdetail.color, cutdetail.qty, cutdetail.qty1, cutdetail.qty2, cutdetail.qty3, cutdetail.qty4, cutdetail.qty5, cutdetail.qty6, " & _
"cutdetail.qty7, cutdetail.qty8, cutdetail.qty9, cutdetail.qty10, cutdetail.qty11, cutdetail.qty12, division.size1, division.size2, division.size3, division.size4, division.size5, division.size6, division.size7, division.size8, division.size9, division.size10, division.size11, " & _
"division.size12 from cutdetail, ivtf, division where cutdetail.cutno = '9702204' and cutdetail.style = ivtf.code and cutdetail.color = ivtf.color and ivtf.division = division.code  group by cutdetail.cutno, cutdetail.style, cutdetail.color , cutdetail.qty1, cutdetail.qty2, " & _
"cutdetail.qty3, cutdetail.qty4, cutdetail.qty5, cutdetail.qty6, cutdetail.qty7, cutdetail.qty8, cutdetail.qty9, cutdetail.qty10, cutdetail.qty11, cutdetail.qty12 , cutdetail.qty, division.size1, division.size2, division.size3, division.size4, division.size5, " & _
"division.size6, division.size7, division.size8, division.size9, division.size10, division.size11, division.size12"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
D_WongCommented:
You could use a variable, for example ;

------------------------------------------------------------

Set comm.ActiveConnection = conn
   
SqlText = "first line of sql statement here"
SqlText = SqlText & "secondline line of sql statement here"
SqlText = SqlText & "etc"

comm.CommandText =SqlText

----------------------------------------------------------------
0
Rob HensonFinance AnalystCommented:
You could make the separate parts as individual strings and then string them together.

For Example:

CutDetStrg = "cutdetail.qty,"
For CutDetCt = 1 to 12
CutDetStrg = CutDetStrg &  "cutdetail.qty" & CutDetCt &","
Next CutDetCt

DivSizeStrg = "division.size,"
For DivSizeCt = 1 to 12
DivSizeStrg = DivSizeStrg & "division.size" & DivSizCt & ","
Next DivSizCt

Open in new window


Repeated for each element

comm.CommandText  = CutDetStrg & DivSizStrg & ...

Hope that helps
Rob H
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.