I'm using Access 97 and I'm trying to use code from MS KB 129096. The first function in method 3 of the article has the following:
Function CalcProduct(R As Report)
Dim tmpAmount As Double
tmpAmount = R![UnitPrice] * R![Quantity]
OrderTotal = OrderTotal + tmpAmount
GrandTotal = GrandTotal + tmpAmount
CalcProduct = tmpAmount
End Function
For what I'm doing (starting real slowly trying to adapt it to what I want to do), I do the following:
Function CalcProduct(R As Report)
Dim tmpAmount As Double
tmpAmount = R![FirstOfGRegTO]
OrderTotal = tmpAmount
GrandTotal = GrandTotal + tmpAmount
CalcProduct = tmpAmount
End Function
FirstOfGRegTO is a field in the table that my report (which uses this function) is based on. The field's datatype is Currency. In the detail section of my report I have the following control:
=CalcProduct([Report])
When I try to run the report with the code shown above, I get the following error:
Runtime error 2465. The database can't find the field FirstOfGRegTO
I've changed the code many times - getting rid of R!, specifying the table name, getting rid of bracketts, using a . instead of !, changing Double to Currency, etc. I keep getting error messages basically saying it can't find the field FirstOfGRegTO. It usually has #Error or #Name in the report where FirstOfGRegTO should print.
I'm trying to adapt this code in order to get the grand total at the end of the report for FirstOfGRegTO (and several other similar fields). When all is said and done, I don't want this field to be on the detail lines of the report, but I do want it in the group footer and in the report footer. I was thinking KB 129096 would help me do this.
Do you know where I'm going wrong?
Function CalcProduct(R As Report)
Dim tmpAmount As Double
tmpAmount = R![UnitPrice] * R![Quantity]
OrderTotal = OrderTotal + tmpAmount
GrandTotal = GrandTotal + tmpAmount
CalcProduct = tmpAmount
End Function
For what I'm doing (starting real slowly trying to adapt it to what I want to do), I do the following:
Function CalcProduct(R As Report)
Dim tmpAmount As Double
tmpAmount = R![FirstOfGRegTO]
OrderTotal = tmpAmount
GrandTotal = GrandTotal + tmpAmount
CalcProduct = tmpAmount
End Function
FirstOfGRegTO is a field in the table that my report (which uses this function) is based on. The field's datatype is Currency. In the detail section of my report I have the following control:
=CalcProduct([Report])
When I try to run the report with the code shown above, I get the following error:
Runtime error 2465. The database can't find the field FirstOfGRegTO
I've changed the code many times - getting rid of R!, specifying the table name, getting rid of bracketts, using a . instead of !, changing Double to Currency, etc. I keep getting error messages basically saying it can't find the field FirstOfGRegTO. It usually has #Error or #Name in the report where FirstOfGRegTO should print.
I'm trying to adapt this code in order to get the grand total at the end of the report for FirstOfGRegTO (and several other similar fields). When all is said and done, I don't want this field to be on the detail lines of the report, but I do want it in the group footer and in the report footer. I was thinking KB 129096 would help me do this.
Do you know where I'm going wrong?