Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Subtotals

Status
Not open for further replies.

charbrad

Technical User
Nov 7, 2002
132
US
I have the below code I am trying to subtotal by date
Code:
MySQL = "SELECT ship_id, adrnam, prtnum, early_shpdte, shpsts, cponum, stgdte, host_ordqty, inpqty, stgqty, sum(host_ordqty-stgqty-inpqty) FROM ShipReport (NOLOCK) where (host_ordqty-stgqty-inpqty <> 0) GROUP BY ship_id, adrnam, prtnum, early_shpdte, shpsts, cponum, stgdte, host_ordqty, inpqty, stgqty ORDER BY early_shpdte, ship_id" 
FOR MyCursor = LBOUND(MyArray,2) TO UBOUND(MyArray,2)
body = body + "<TR><TD BGCOLOR=""" & SHADE & """>" & MyArray(0,MyCursor) & "&nbsp;</TD><TD WIDTH=300 ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """>" & 
MyArray(1,MyCursor) & "</TD><TD BGCOLOR=""" & SHADE & """>" & MyArray(2,MyCursor) & "&nbsp;<TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(3,MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(4,MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(5,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """>" & MyArray(6,MyCursor) & "</TD><TD ALIGN=""CENTER"" BGCOLOR=""" & SHADE & """>" & MyArray(7,MyCursor) & "</TD><TD BGCOLOR=""" & SHADE & """>" & MyArray(8,MyCursor) & " </TD><TD BGCOLOR= """ & SHADE & """>" & MyArray(9,MyCursor) & " 
</TD><TD ALIGN=""RIGHT"" BGCOLOR=""" & SHADE & """>" & MyArray(10,MyCursor) & " </TD></TR>" & vbcrlf
IF SHADE = "#FFFFFF" THEN SHADE = "#DDDDDD" ELSE SHADE = "#FFFFFF"
MySQL = "SELECT max(early_shpdte), sum(host_ordqty), sum(inpqty), sum(stgqty) from ShipReport group by early_shpdte"
body = body + "<TR class=""Set0""><td BGCOLOR=""#AAAAAA"" ALIGN=""CENTER"" COLSPAN=7><b>Total:</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(7, MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(8, MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(9, 
MyCursor) & "</TD><TD ALIGN=""RIGHT"" BGCOLOR=""#99CC99""><b>" & MyArray(10, MyCursor) & "</TD></TR>" & vbcrlf
but I am getting the incorrect results I am getting subtotal by each line instead of subtotal by date. Below is an example of the output:
Code:
Order #		Customer Location	Item Number	Ship Date	Status	Customer PO#	Stage Date	Qty Ordered	Picked Qty	Staged Qty	
00821	 		NJ		  05300 	9/17/2007	Picked	43817				900	765 			   0 	   
											                             Total:	 900	765			   0	

00837	 		NY		 982328 	9/17/2007	Picked	002630906116			36	19 			   0 	 
											                             Total:	    36	19			   0

Can someone help me out?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top