smgeorge99
Programmer
I have a report that allows the user to select certain criteria for the report. In the report's Open event, I open the criteria form in Dialog mode, so that the user has to make the selection. Here is the code:
Private Sub Report_Open(Cancel As Integer)
'Open the form for date input
DoCmd.OpenForm "InputDate", acNormal, , , acFormEdit, acDialog
End Sub
When the user makes their selection, they hit the OK button, which hides the form. The report then uses the values in the hidden form. In the report's close event, I close the hidden form.
In addition to the OK button in the form, there is a Cancel button in the form. When the user hits cancel, the form closes, but the report still tries to open and fails because the fields it's looking for in the form are not available.
My question is this: How do I implement the Cancel button so that if the user hits the cancel button in the form the reports closes gracefully?
Private Sub Report_Open(Cancel As Integer)
'Open the form for date input
DoCmd.OpenForm "InputDate", acNormal, , , acFormEdit, acDialog
End Sub
When the user makes their selection, they hit the OK button, which hides the form. The report then uses the values in the hidden form. In the report's close event, I close the hidden form.
In addition to the OK button in the form, there is a Cancel button in the form. When the user hits cancel, the form closes, but the report still tries to open and fails because the fields it's looking for in the form are not available.
My question is this: How do I implement the Cancel button so that if the user hits the cancel button in the form the reports closes gracefully?