M
MarieM via AccessMonster.com
I have a Purchase Order database which includes the Purchase Order form with
a subform which contains the PO details.
The form includes a button which when the user clicks the PO displays in
Print Preview mode.
Attached to the report's On Open property I have the following code which
checks to determine if the total of the PO is over $5000. If so, a message
displays alerting the user and the report is canceled.
This is working great, however, it also displays the the "Open Report
canceled action" message which I would like to hide from the user.
I tried adding the following error handling code without any luck. The
message still displays.
Is this the appropriate place to put the code and if so, could someone please
give me a hand with the code.
Thanks in advance for your help!
Marie
Private Sub Report_Open(Cancel As Integer)
On Error GoTo OpenReport_Err
If DSum("[ExtendedPrice]", "qryPODetailssubrpt", "PONumber = PONumber") >
5000 Then
MsgBox "The PO Total must not exceed $5000."
Cancel = True
'On Error Resume Next
Exit Sub
Else
DoCmd.OpenReport "rptPurchaseOrder", acViewPreview
DoCmd.Maximize
End If
OpenReport_End:
Exit Sub
OpenReport_Err:
If Err.Number = 2501 Then
Resume OpenReport_End
Else
MsgBox Err.Number & " " & Err.Description
Resume OpenReport_End
End If
End Sub
a subform which contains the PO details.
The form includes a button which when the user clicks the PO displays in
Print Preview mode.
Attached to the report's On Open property I have the following code which
checks to determine if the total of the PO is over $5000. If so, a message
displays alerting the user and the report is canceled.
This is working great, however, it also displays the the "Open Report
canceled action" message which I would like to hide from the user.
I tried adding the following error handling code without any luck. The
message still displays.
Is this the appropriate place to put the code and if so, could someone please
give me a hand with the code.
Thanks in advance for your help!
Marie
Private Sub Report_Open(Cancel As Integer)
On Error GoTo OpenReport_Err
If DSum("[ExtendedPrice]", "qryPODetailssubrpt", "PONumber = PONumber") >
5000 Then
MsgBox "The PO Total must not exceed $5000."
Cancel = True
'On Error Resume Next
Exit Sub
Else
DoCmd.OpenReport "rptPurchaseOrder", acViewPreview
DoCmd.Maximize
End If
OpenReport_End:
Exit Sub
OpenReport_Err:
If Err.Number = 2501 Then
Resume OpenReport_End
Else
MsgBox Err.Number & " " & Err.Description
Resume OpenReport_End
End If
End Sub