hi i'm trying to update total order cost in order table , basically what i want when i edit order item table such as changing quantity then it automatically update the total cost in order table
i mean if there are two order items in orderitemtable such as for item 1 and the hire cost is £20 and quantity is 2 for each item and these two different orderitems ID are under one orderID and it calculates the total order cost but doesnot shows in the order Table
als if i try to edit orderitem form such as changing quantity
it only change the total order cost on the order form but doesnot change the total order cost in order table
i think i did not explain properly so here is the coding
Dim strSQL As String
Dim strAddItem As String
Dim strOrderID As String
Call clearOrderItems List
decTotal = 0
strOrderID = txtOrderID.Valu e
strSQL = "SELECT tblOrderItem.* "
strSQL = strSQL & "FROM tblOrderItem "
strSQL = strSQL & "WHERE tblOrderItem.[OrderID] = " & "'" & strOrderID & "' ;"
'MsgBox strSQL
Set rstOrderItemDet ails = dbase.OpenRecor dset(strSQL, dbOpenDynaset)
strAddItem = "OrderItemI D" & ";" & "ToolID" & ";" & "HireDate" & ";" & "TotalCost"
lstOrderItems.A ddItem (strAddItem)
strAddItem = ""
While Not rstOrderItemDet ails.EOF
strAddItem = rstOrderItemDet ails("OrderItem ID") & ";" & rstOrderItemDet ails("ToolID") & ";" & rstOrderItemDet ails("HireDate" ) & ";" & rstOrderItemDet ails("TotalCost ")
decTotal = decTotal + Format((rstOrde rItemDetails("Q uantity") * rstOrderItemDet ails("HireCost" )), "0.00")
lstOrderItems.A ddItem (strAddItem)
rstOrderItemDet ails.MoveNext
Wend
txtTotalCost.Va lue = decTotal
rstOrderItemDet ails.Close
Call UpdateTotalCost
End Sub
please help very very urgent
thanks
i mean if there are two order items in orderitemtable such as for item 1 and the hire cost is £20 and quantity is 2 for each item and these two different orderitems ID are under one orderID and it calculates the total order cost but doesnot shows in the order Table
als if i try to edit orderitem form such as changing quantity
it only change the total order cost on the order form but doesnot change the total order cost in order table
i think i did not explain properly so here is the coding
Dim strSQL As String
Dim strAddItem As String
Dim strOrderID As String
Call clearOrderItems List
decTotal = 0
strOrderID = txtOrderID.Valu e
strSQL = "SELECT tblOrderItem.* "
strSQL = strSQL & "FROM tblOrderItem "
strSQL = strSQL & "WHERE tblOrderItem.[OrderID] = " & "'" & strOrderID & "' ;"
'MsgBox strSQL
Set rstOrderItemDet ails = dbase.OpenRecor dset(strSQL, dbOpenDynaset)
strAddItem = "OrderItemI D" & ";" & "ToolID" & ";" & "HireDate" & ";" & "TotalCost"
lstOrderItems.A ddItem (strAddItem)
strAddItem = ""
While Not rstOrderItemDet ails.EOF
strAddItem = rstOrderItemDet ails("OrderItem ID") & ";" & rstOrderItemDet ails("ToolID") & ";" & rstOrderItemDet ails("HireDate" ) & ";" & rstOrderItemDet ails("TotalCost ")
decTotal = decTotal + Format((rstOrde rItemDetails("Q uantity") * rstOrderItemDet ails("HireCost" )), "0.00")
lstOrderItems.A ddItem (strAddItem)
rstOrderItemDet ails.MoveNext
Wend
txtTotalCost.Va lue = decTotal
rstOrderItemDet ails.Close
Call UpdateTotalCost
End Sub
please help very very urgent
thanks
Comment