Run-time error 2501

Tumby

Registered User.
Local time
Today, 11:38
Joined
Jan 12, 2009
Messages
64
I have a form- View Reports this has a combo box listing all the Reports available. When the user clicks on a report the user is asked to put in certain info such as Start Dates and Ending Dates.

However if the user cancels this operation when the Parameter box is on the screen the Run-time error 2501 appears, asking to debug.
My code for the View button is-

Option Compare Database
Option Explicit
Private Sub Print_Click()
End Sub
Private Sub View_Click()

DoCmd.OpenReport cboReports, acPreview
End Sub
Private Sub ElectricDateFinder_Click()
On Error GoTo Err_ElectricDateFinder_Click
Dim stDocName As String
stDocName = "ReferBackDateElectricity"
DoCmd.OpenReport stDocName, acPreview
Exit_ElectricDateFinder_Click:
Exit Sub
Err_ElectricDateFinder_Click:
MsgBox Err.Description
Resume Exit_ElectricDateFinder_Click

End Sub


Private Sub View_Click()
This is the section it highlights for debugging.
DoCmd.OpenReport cboReports, acPreview
End Sub

Please can someone help!
 
Your report is using the parameters and is requesting the parameters from the user.

Though there are better ways of resolving this.... probably what you are looking for is turning of the warnings....

Private Sub View_Click()
On error resume next ' ignore any errors
DoCmd.OpenReport cboReports, acPreview
On error goto 0 ' restart popping errors.
End Sub
 
namliam,
Thank You VERY much that has solved my problem.

Tho' it was a minor error, I didn't want the user to try debugging!!!!

Thanks again, it works fine.
 

Users who are viewing this thread

Back
Top Bottom