I am in the process of building a billing system through access and I have run into a stumbling block. I am trying to modify a lookup of product infomation with a case such as "if calling charges is selected, open CDRQ, sum all calling charges for the current date where the current open form's customerID is equal to that of CDRQ's CustomerID" This has been a very tricky equation taht eludes me. Here is the code that I have written thus far:
CDRQ contains Calling Data with "CustomerID" and "Charge" as the only relevant fields and CDRQ is a Query
Manage_Orders is the current open form with "customerID" as the only relevant field
Private Sub Product_AfterUpdate()
On Error GoTo Err_Product_AfterUpdate
Dim strFilter As String
Dim CDRQ As Recordset
Dim Manage_Orders As Recordset
Dim Sumit As String
Set CDRQ = [CDRQ]
Set Manage_Orders = [Forms]![Manage Orders].[CustomerID]
Set Sumit = DSum("Charge", "CDRQ", [CDRQ]![CustomerID] = [Manage Orders]![CustomerID])
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me.ProductID
' Look up product's unit price and assign it to UnitPrice control.
Me.UP = IIf(DLookup("ProductID", "Products 1", strFilter) = "158", Sumit, DLookup("UnitPrice", "Products 1", strFilter))
' Me.UP = DLookup("UnitPrice", "Products 1", strFilter)
' Look up product's accounting number and assign it to AccountingID control.
Me.AID = DLookup("AccountingID", "Products 1", strFilter)
Exit_Product_AfterUpdate:
Exit Sub
Err_Product_AfterUpdate:
MsgBox Err.Description
Resume Exit_Product_AfterUpdate
End Sub
Any help would be appreciated. I need this to basically sum all the charges in CDRQ when Challing Charges is selected and then apply that sum to the unit price where the customerID's Match.
Thanks.
Tony
CDRQ contains Calling Data with "CustomerID" and "Charge" as the only relevant fields and CDRQ is a Query
Manage_Orders is the current open form with "customerID" as the only relevant field
Private Sub Product_AfterUpdate()
On Error GoTo Err_Product_AfterUpdate
Dim strFilter As String
Dim CDRQ As Recordset
Dim Manage_Orders As Recordset
Dim Sumit As String
Set CDRQ = [CDRQ]
Set Manage_Orders = [Forms]![Manage Orders].[CustomerID]
Set Sumit = DSum("Charge", "CDRQ", [CDRQ]![CustomerID] = [Manage Orders]![CustomerID])
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me.ProductID
' Look up product's unit price and assign it to UnitPrice control.
Me.UP = IIf(DLookup("ProductID", "Products 1", strFilter) = "158", Sumit, DLookup("UnitPrice", "Products 1", strFilter))
' Me.UP = DLookup("UnitPrice", "Products 1", strFilter)
' Look up product's accounting number and assign it to AccountingID control.
Me.AID = DLookup("AccountingID", "Products 1", strFilter)
Exit_Product_AfterUpdate:
Exit Sub
Err_Product_AfterUpdate:
MsgBox Err.Description
Resume Exit_Product_AfterUpdate
End Sub
Any help would be appreciated. I need this to basically sum all the charges in CDRQ when Challing Charges is selected and then apply that sum to the unit price where the customerID's Match.
Thanks.
Tony
Last edited: