M
MES via AccessMonster.com
I keep getting 'runtime error 2501', and I am unsure of what code to use to
fix. Here is what I'm doing.
Click open a report, then the report 'On Open' event triggers a form to open.
This form allows user to select the parameter (in this case, the employee) to
use in the query that populates the report. All works fine, and I am able to
run the report for the employee I select. My problem is that I have a cancel
button on my select form of which my intent is to have it cancel what I'm
doing and go back to my main menu, but I am getting the runtime error. The
command I have for my cancel button is 'Close'. This is my code for both the
report and the form:
1. REPORT CODE
Private Sub Report_Close()
DoCmd.Close acForm, "Employees - Select2"
End Sub
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open Employees - Select2 form
DoCmd.OpenForm "Employees - Select2", , , , , acDialog
DoCmd.Maximize
' Cancel report if user clicked the cancel button
If IsLoaded("Employees - Select2") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
2. FORM CODE
Private Sub Cancel_Click()
DoCmd.Close 'Close Form
End Sub
Private Sub Select_Employee_Click()
Me.Visible = False
End Sub
Can anyone tell me what my code is missing? Also, where would I put the
missing code?
Thanks in advance.
fix. Here is what I'm doing.
Click open a report, then the report 'On Open' event triggers a form to open.
This form allows user to select the parameter (in this case, the employee) to
use in the query that populates the report. All works fine, and I am able to
run the report for the employee I select. My problem is that I have a cancel
button on my select form of which my intent is to have it cancel what I'm
doing and go back to my main menu, but I am getting the runtime error. The
command I have for my cancel button is 'Close'. This is my code for both the
report and the form:
1. REPORT CODE
Private Sub Report_Close()
DoCmd.Close acForm, "Employees - Select2"
End Sub
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open Employees - Select2 form
DoCmd.OpenForm "Employees - Select2", , , , , acDialog
DoCmd.Maximize
' Cancel report if user clicked the cancel button
If IsLoaded("Employees - Select2") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
2. FORM CODE
Private Sub Cancel_Click()
DoCmd.Close 'Close Form
End Sub
Private Sub Select_Employee_Click()
Me.Visible = False
End Sub
Can anyone tell me what my code is missing? Also, where would I put the
missing code?
Thanks in advance.