Error Handling using No Data (on report) - need to repress OpenReport msg

D

DaveSwain

Hello,

I have an access form that does an openReport based on selectio
criteria; see code below:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data was found for your criteria, The Report will not
run unless Data is found"
Cancel = True
End Sub

.... however after my error message(MsgBox) is displayed, Another error
message pops up and says "The OpenReport Action was Canceled"

I do NOT want to display that second message, only my first 'MsgBox'
error message.

Is there anyway that I can repress the second pop-up error message(and
still have the report cancel from opening with no data?

This code is in the report btw.

The code that calls it in the form is here:

....
DoCmd.OpenReport stDocName, acPreview, , "StoreID = " & cmbFilter
....

How can I repress that second message??

thank you,
David
 
G

Guest

Dave,

Try entering the following line of code in your module which should suppress
the warning.

DoCmd.SetWarnings False

HTH
Mark
 
G

Guest

If you are going to use 'DoCmd.SetWarnings False' then put it before your
line of code that opens the Report. You must make sure that you set warnings
back to True either immediately after opening the Report or before the end of
your procedure. To do this use:

DoCmd.SetWarnings True

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top