E
Eric Brenner
In one of my reports, I have a textbox control that, when viewed, will
display the cost of a transaction. This control calls a function that
grabs the correct cost info. See below:
The name if the text box is txtProductDescription.
The control source on the textbox control is =CostInfo([TransactionID],
[HistoryID])
Function CostInfo(TransactionID As Integer, HistoryID As Integer)
Select Case TransactionID
Case 2 'Repair
CostInfo = DLookup("[RepairCost]", "tblRepair",
"[HistoryID] = " & HistoryID)
If IsNull(CostInfo) Then CostInfo = 0#
lngRepairCost = lngRepairCost + CostInfo
Case 3 'Change Location
CostInfo = DLookup("[PriceCharged]", "tblChangeLocation",
"[HistoryID] = " & HistoryID)
If IsNull(CostInfo) Then CostInfo = 0#
lngLocationCost = lngLocationCost + CostInfo
Case 5 'Calibration
CostInfo = DLookup("[CalibrationCost]", "tblCalibration",
"[HistoryID] = " & HistoryID)
If IsNull(CostInfo) Then CostInfo = 0#
lngCalibrationCost = lngCalibrationCost + CostInfo
End Select
End Function
I want to sum this control. How do I do this?
display the cost of a transaction. This control calls a function that
grabs the correct cost info. See below:
The name if the text box is txtProductDescription.
The control source on the textbox control is =CostInfo([TransactionID],
[HistoryID])
Function CostInfo(TransactionID As Integer, HistoryID As Integer)
Select Case TransactionID
Case 2 'Repair
CostInfo = DLookup("[RepairCost]", "tblRepair",
"[HistoryID] = " & HistoryID)
If IsNull(CostInfo) Then CostInfo = 0#
lngRepairCost = lngRepairCost + CostInfo
Case 3 'Change Location
CostInfo = DLookup("[PriceCharged]", "tblChangeLocation",
"[HistoryID] = " & HistoryID)
If IsNull(CostInfo) Then CostInfo = 0#
lngLocationCost = lngLocationCost + CostInfo
Case 5 'Calibration
CostInfo = DLookup("[CalibrationCost]", "tblCalibration",
"[HistoryID] = " & HistoryID)
If IsNull(CostInfo) Then CostInfo = 0#
lngCalibrationCost = lngCalibrationCost + CostInfo
End Select
End Function
I want to sum this control. How do I do this?