By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

how to update order table

P: 3
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 clearOrderItemsList
decTotal = 0
strOrderID = txtOrderID.Value

strSQL = "SELECT tblOrderItem.* "
strSQL = strSQL & "FROM tblOrderItem "
strSQL = strSQL & "WHERE tblOrderItem.[OrderID] = " & "'" & strOrderID & "' ;"
'MsgBox strSQL

Set rstOrderItemDetails = dbase.OpenRecordset(strSQL, dbOpenDynaset)

strAddItem = "OrderItemID" & ";" & "ToolID" & ";" & "HireDate" & ";" & "TotalCost"
lstOrderItems.AddItem (strAddItem)
strAddItem = ""
While Not rstOrderItemDetails.EOF

strAddItem = rstOrderItemDetails("OrderItemID") & ";" & rstOrderItemDetails("ToolID") & ";" & rstOrderItemDetails("HireDate") & ";" & rstOrderItemDetails("TotalCost")
decTotal = decTotal + Format((rstOrderItemDetails("Quantity") * rstOrderItemDetails("HireCost")), "0.00")
lstOrderItems.AddItem (strAddItem)
txtTotalCost.Value = decTotal
Call UpdateTotalCost
End Sub

please help very very urgent
Apr 22 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 931
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?

Apr 22 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.