On No Data doesn't work -Access 97

T

Tracey

I set up a command button on a form using the wizard.
Event procedure uses "DoCmd.OpenReport".

I then set up the "On No Data" property in the report to
display a message box, then cancel = true.

The "On No Data" procedure works fine when opening the
report straight from the database window, but my users
will be using the button on the form to open the report.

Unfortunately, I get an error that the "OpenReport action
was cancelled" when I use the command button to open the
report. Error msg: "You used a method of the DoCmd
object to carry out an action in VB, but then clicked
Cancel in a dialog box."

When I click OK, it goes away, but I do not want my users
to see this error message

Any thoughts? I cannot find any Access 97 Knowledge Base
articles on "NoData" or "OnNoData".

Thanks
 
R

Rick Brandt

Tracey said:
I set up a command button on a form using the wizard.
Event procedure uses "DoCmd.OpenReport".

I then set up the "On No Data" property in the report to
display a message box, then cancel = true.

The "On No Data" procedure works fine when opening the
report straight from the database window, but my users
will be using the button on the form to open the report.

Unfortunately, I get an error that the "OpenReport action
was cancelled" when I use the command button to open the
report. Error msg: "You used a method of the DoCmd
object to carry out an action in VB, but then clicked
Cancel in a dialog box."

When I click OK, it goes away, but I do not want my users
to see this error message

Any thoughts? I cannot find any Access 97 Knowledge Base
articles on "NoData" or "OnNoData".

The code is working as expected. The OpenReport action _was_ cancelled. Your button
code just needs to trap for errors and ignore when the error number = 2501.

On Error GoTo ErrHandler

DoCmd.OpenReport blah blah...

Egress:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
'ignore
Case Else
(your normal error handling code)
End Select
Resume Egress
End Sub
 

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

Similar Threads

Cancel = True - error 2
no data on reports 2
No Data Problem 2
Annoying errer message 1
No data event function 2
Report OnNoData event error 2
Error 2501 4
No data report 2

Top