Shape My Command-Please
Here's the plan. I have 2 tables not related except for a jobid field. I set up a temp table and run a sql statment on each table to insert records into the temp table from the original tables. Works great. Then I run sql statements on the temp table to create a command. See code below. Each command in iteself runs fine, but I need to join the 2 commands together inorder to run a report. For some reason I get a syntax error when I join the commands with append the cmd and pcmd together. The only thing I am trying to accomplish is to run a report like:
id qty
2412 20
2414 30
2416 40
plid plqty
321 10
215 15
336 30
strSQL = "Select jobid,id, sum(qty) as SumOfQty from " & ausername & "report Group By jobid,id"
pstrSQL = "Select jobid, plid, sum(plqty) as plSumOfQty from " & ausername & "report Group By jobid, plid"
With cmd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = "SHAPE {" & strSQL & "} As cmdGroup1 Compute cmdGroup1 BY 'id'"
.Execute
End With
With pcmd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = " SHAPE {" & pstrSQL & " } As pcmdGroup2 Compute pcmdGroup2 BY 'plid'"
.Execute
End With
|