jeffkwells2003
asked on
Access 2007 - Cancelling openreport from VBA code
I have a report which is opened from a menu. This report opens a dialog form from the report 'On Open' event to get a date range. On this form I have a 'Cancel' button in case the user changes their mind and this closes the form and sets a flag. This flag is checked by VBA in the report 'on open' event and exits from the report with the statement 'Cancel=true'. However, this produces the error 2501 "The OpenReport Action was cancelled". I do not get this error if I open the report directly (ie not from my Menu form)
cancelrep = False
DoCmd.OpenForm "ChooseRepMonthYear", , , , , acDialog
If cancelrep Then
Cancel = True
Exit Sub
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Gary