I use the following code the following code to open a report from the On Click event of a button:
Private Sub Label180_Click()
On Error GoTo Err_GiftAidGeneralPurpose_Click
Dim stDocName As String
stDocName = "GiftAidGeneralPurpose"
DoCmd.OpenReport stDocName, acPreview
Exit_GiftAidGeneralPurpose_Click:
Exit Sub
Err_GiftAidGeneralPurpose_Click:
MsgBox Err.Description
Resume Exit_GiftAidGeneralPurpose_Click
End Sub
This procedure opens the "GiftAidGeneralPurpose" report fine - whatever the data generated from the underlying query - except that, when the basis for the report (GiftAid being "Yes") has no "Yes's"
The field that sums (by an IIf statement) the "Yes's" reads: #Error. This also appears in the sum for receipts affected by this Gift Aid. What I was hoping to do was to use a message box to advise the user that there were no receipts with Gift Aid and NOT open the report. I have started reading about the various error handling procedures, but I am none-the-wiser!
Any assistance would be greatly appreciated.
Ted.
Private Sub Label180_Click()
On Error GoTo Err_GiftAidGeneralPurpose_Click
Dim stDocName As String
stDocName = "GiftAidGeneralPurpose"
DoCmd.OpenReport stDocName, acPreview
Exit_GiftAidGeneralPurpose_Click:
Exit Sub
Err_GiftAidGeneralPurpose_Click:
MsgBox Err.Description
Resume Exit_GiftAidGeneralPurpose_Click
End Sub
This procedure opens the "GiftAidGeneralPurpose" report fine - whatever the data generated from the underlying query - except that, when the basis for the report (GiftAid being "Yes") has no "Yes's"
The field that sums (by an IIf statement) the "Yes's" reads: #Error. This also appears in the sum for receipts affected by this Gift Aid. What I was hoping to do was to use a message box to advise the user that there were no receipts with Gift Aid and NOT open the report. I have started reading about the various error handling procedures, but I am none-the-wiser!
Any assistance would be greatly appreciated.
Ted.