|
-
Mar 2nd, 2005, 07:46 AM
#7
Thread Starter
Lively Member
Re: SQL Statement Count Total Quantity
Thanks,Flair.
However,I encounter another problems then.I will display out all the model and total quantity in the datagrid by two columns.When the total quantity is less than the set TargetQty,it will display out vbRed and if the total quantity meet the TargetQty,it will display vbGreen.To get the Total quantity,Qty should add the Exceed Packout for that day as shown in the code below so that it can compared with the TargetQty.But,dunno why some of the data should be green,but it turns to Red because it doesn't add up my Qty.
Maybe my explanation is not good enough.Below attached is the coding that I do.Hope anyone here can solve the problem for me.Thank You.
VB Code:
Private Sub DisplayGrid ()
.....
fg.Clear
sSQL = "SELECT * FROM PackQty_View"
Set oRs1 = oShip.Execute(sSQL)
'Run FROM PackQty_View and get ModelDefined(Ex:- I730 and I90) and Qty by 2 and 11
Do Until oRs1.EOF
fg.Rows = oRs1.RecordCount + 1
fg.TextMatrix(Row, 1) = oRs1!Qty
Qty = oRs1!Qty
ModelDefined = oRs1!ModelDefined
oRs1.MoveNext
Loop
DisplaySQL = "SELECT Model,TargetQty,Exceed FROM DataGrid"
Set rst = oSQL.Execute(DisplaySQL)
fg.ColWidth(0) = 2900
fg.ColWidth(1) = 1600
fg.ColAlignment(0) = flexAlignLeftCenter
fg.ColAlignment(1) = flexAlignLeftCenter
Row = 0
fg.TextMatrix(Row, 0) = "Model"
fg.TextMatrix(Row, 1) = "Total Quantity"
Row = Row + 1
Do Until rst.EOF
fg.Rows = rst.RecordCount + 1
fg.TextMatrix(Row, 0) = rst!Model
DisplaySQL = "SELECT * FROM DataGrid"
Set rst = oSQL.Execute(DisplaySQL)
If fg.TextMatrix(Row, 0) <> oRs1!ModelDefined Then 'Izit i compare like this make it compare only with the Model in the first row in PackQty_View instead of comparing with the second row?
Qty = 0
Else
fg.TextMatrix(Row, 1) = oRs1!Qty
Qty = oRs1!Qty
oRs1.MoveNext
End If
TargetQty = rst!TargetQty
Exceed = rst!Exceed
sTotal = Qty + Exceed
fg.TextMatrix(Row, 1) = sTotal
If fg.TextMatrix(Row, 1) < TargetQty Then
fg.Row = Row
fg.Col = 1
fg.CellBackColor = vbRed
ElseIf fg.TextMatrix(Row, 1) >= TargetQty Then
fg.Row = Row
fg.Col = 1
fg.CellBackColor = vbGreen
End If
Row = Row + 1
rst.MoveNext
Loop
Exit Sub
End Sub
Human Knowledge Belongs To The World 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|