how to update order table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 125a29
    New Member
    • Apr 2010
    • 3

    how to update order table

    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
  • patjones
    Recognized Expert Contributor
    • Jun 2007
    • 931

    #2
    Based on the code that you posted, there is no reason to believe that the table itself would be updated. You are defining a SQL string and using it to pull data from the table and display it on the form. I don't see anything explicit here that would update the table.

    However, at the bottom I see that you are calling another routine, UpdateTotalCost. I think that is what we need to look at. Can you post the code for it?

    Pat

    Comment

    Working...