I have a Purchase form with a subform for products purchased. The subform contains some calculated fields, one is for consignment fees (based on a percentage rate * extended cost). The calculated field for the consignment fee works fine (in subform). I tried to create a calculated field to sum the consignment fees, but I get errors in ALL calculated fields. So, I have tried a user-defined function that uses DSum() to total the consignment fees based on the "PurchID". When called, it calculates, but gives me the wrong total and is off by quite a bit (showing on main form). Or is there another way I can get a correct total based on a calculated field.
Calculated field (txtFee) control source: =IIf([OnConsign],Round(([ConsignRate]/100),2)*[txtConsignAmt],0)
VBA code is as follows:
Private Function SumFees(iPurID As Integer) As Double
SumFees = DSum(Me![txtFee], "tblPurchItems", "[PurchID] = " & iPurID)
End Function
Fees calculated on datasheet show: $18.53, 16.50, 18.53, 13.20
This should total $66.76
SumFees function shows $52.80
Don't understand why the total is not correct. Any help is greatly appreciated.
bp
Calculated field (txtFee) control source: =IIf([OnConsign],Round(([ConsignRate]/100),2)*[txtConsignAmt],0)
VBA code is as follows:
Private Function SumFees(iPurID As Integer) As Double
SumFees = DSum(Me![txtFee], "tblPurchItems", "[PurchID] = " & iPurID)
End Function
Fees calculated on datasheet show: $18.53, 16.50, 18.53, 13.20
This should total $66.76
SumFees function shows $52.80
Don't understand why the total is not correct. Any help is greatly appreciated.
bp