OpenReport function canceled problem

  • Thread starter Thread starter thread
  • Start date Start date
T

thread

Hi all,

I'm facing a problem when i'm working with several reports/form
the switchboard is activating a report but the report is getting data
from a form that filtering it,
when i'm pressing on cancel for the form i will get
OpenReport function canceled...2501
how should i trap and bypass this error so it will not appear to the
user when doing canceling to the form
 
Here the code from one of my databases.

Check the code after the last label (Err)
========
Private Sub cmdPrint_Click()

Const RPT_BATCHING As String = "rptBatching"

On Error GoTo cmdPrint_Click_Err
DoCmd.OpenReport RPT_BATCHING, acViewPreview, , , acIcon
DoEvents
DoCmd.RunCommand acCmdPrint
DoEvents
DoCmd.Close acReport, RPT_BATCHING, acSaveNo
DoEvents

cmdPrint_Click_Exit:
On Error Resume Next
Exit Sub

cmdPrint_Click_Err:
Select Case Err.Number
Case 2501
If CurrentProject.AllReports(RPT_BATCHING).IsLoaded Then
DoCmd.Close acReport, RPT_BATCHING, acSaveNo
End If
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf &
vbCrLf & _
"(Programmer's note: Form_frmBatching.cmdPrint_Click)", _
vbOKOnly + vbCritical, "Run-time Error!"
End Select
Resume cmdPrint_Click_Exit
End Sub
========
 
from some reason its not working becaouse the application working with
a third body
form->(report)form->report
so when the second form is been canceled so the error is raised
the only way i found a solution for this its but changing the
configuration in the option going to the tab of general and changing it
to
"Break on Unhandled Errors".

Ken Sheridan ëúá:
 
Apologies for the delay in replying.

Have you checked to see what the setting is for the Error Trapping option
(Tools|Options|General from the VBA menu bar). If its not 'Break on
Unhandled Errors' then change it to that.

Ken Sheridan
Stafford, England
 
Back
Top