I have a report that I open that pull its data from a form that builds a where string. Opening the report first opens the form, where I enter criteria, and then pulls matching records from a table, opens the report, and closes the form. The code on the report is below.
I used this code on a similar report that also pulled its data from a form (the difference was that that form supplied criteria to an actual query - my new form builds the where string from criteria itself). So, the problem is that I get an error:
Compile error: Sub or Function not defined when I try to open the report and it points to line 16 below (the code to cancel opening the report if the user selects the cancel button on the criteria form). If I comment out this line, the code works fine, opening the report properly. However, if the user selects the cancel button on the criteria form, the report still opens displaying all data.
Any ideas would be most appreciated! Thank you.
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Private Sub Report_Close()
- DoCmd.close acForm, "Survey Form"
- 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 Survey Criteria Dialog
- DoCmd.OpenForm "Survey Form", , , , , acDialog
- ' Cancel Report if User Clicked the Cancel Button
- If IsLoaded("Survey Form") = False Then cancel = True
- ' Set public variable to false to indicate that the
- ' Open event is completed
- bInReportOpenEvent = False
- End Sub