Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

stop report opening if no data ACCESS 2010

I have the message no data for report in the ON NO DATA event, but the report still opens.  How can I prevent the report opening when there is no data?

Sandra
Avatar of chaau
chaau
Flag of Australia image

You need to set the Cancel parameter to TRUE:
Private Sub Report_NoData(Cancel As Integer)
    ' display your custom message box here
    Cancel = True
End Sub

Open in new window

You will also need to handle the error message your main application will get when the report fails to open.

I cannot remember what the error number is, but I just use a Resume Next after testing for that error.
ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

Thanks for the error handling code.  This worked perfectly.

Sandra