J
Joan
Hi,
I have a report with a total control that is to display the sum of the
totals of three subreports. Currently setting the control source in the
property sheet is not working in Access 2003 because as I understand it, the
security level of this edition is so high that it will not accept
calculations as the control source of a control. Consequently, no total
shows on the main report. I was hoping that a work-around might be to set
the control source in VBA code. When I try to do this in the On Open event
of the main report, I get a run-time error 2455: " You entered an
expression that has an invalid reference to the property Form/Report." I
have the following code written for the On Open event:
Private Sub Report_Open(Cancel As Integer)
Reports!rptInvoiceStatement!txtPay =
nnz(Reports!rptInvoiceStatement!rptInvoiceDogs!txtSumSalesPrice) +
nnz(Reports!rptInvoiceStatement!rptInvoiceCharges!txtSumTotCharge) +
nnz(Reports!rptInvoiceStatement!InvoiceAdjustments!txtAdjTot)
End Sub
nnz is a public function that checks to see if the total of a subreport is a
number ( in other words, if there are any records for the subreport based on
report parameters). If it isn't a number, the function sets the result to 0.
Below is the public function:
Public Function nnz(testvalue As Variant) As Variant
If Not (IsNumeric(testvalue)) Then
nnz = 0
Else
nnz = testvalue
End If
End Function
Why am I getting the run time message above?
Joan
I have a report with a total control that is to display the sum of the
totals of three subreports. Currently setting the control source in the
property sheet is not working in Access 2003 because as I understand it, the
security level of this edition is so high that it will not accept
calculations as the control source of a control. Consequently, no total
shows on the main report. I was hoping that a work-around might be to set
the control source in VBA code. When I try to do this in the On Open event
of the main report, I get a run-time error 2455: " You entered an
expression that has an invalid reference to the property Form/Report." I
have the following code written for the On Open event:
Private Sub Report_Open(Cancel As Integer)
Reports!rptInvoiceStatement!txtPay =
nnz(Reports!rptInvoiceStatement!rptInvoiceDogs!txtSumSalesPrice) +
nnz(Reports!rptInvoiceStatement!rptInvoiceCharges!txtSumTotCharge) +
nnz(Reports!rptInvoiceStatement!InvoiceAdjustments!txtAdjTot)
End Sub
nnz is a public function that checks to see if the total of a subreport is a
number ( in other words, if there are any records for the subreport based on
report parameters). If it isn't a number, the function sets the result to 0.
Below is the public function:
Public Function nnz(testvalue As Variant) As Variant
If Not (IsNumeric(testvalue)) Then
nnz = 0
Else
nnz = testvalue
End If
End Function
Why am I getting the run time message above?
Joan