No Data Problem

  • Thread starter Thread starter RBDU
  • Start date Start date
R

RBDU

Hello All, thanking anyone for a reply. A97.

Have a problem with the event in NoData for a report based on a query with
two tables.

I have put code in it which works when designing the report but when I click
on a command button on the main form my message comes up for no data but
then I get the access error message for Openreport action was cancelled,
which I have to click on to close.

The code for nodata is straight out of access help. That is, the message
part then cancel = true.

Any suggestions.

Regards Peter
 
Use error handling in the Click event of your button to ignore error 2501.

This message is Access way of notifying your button Click procedure that the
report did not open. Sometimes that is really useful to know, but if you
already popped up a MsgBox in the report's NoData event you may just want to
ignore this 2nd message.

Example of ignoring the error:

Private Sub cmdPrint_Click()
On Error Goto Err_Handler:

DoCmd.OpenReport "Report1"

Exit_Handler:
Exit sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & "L " & Err.Description
End If
End Sub
 
Thank you

Allen Browne said:
Use error handling in the Click event of your button to ignore error 2501.

This message is Access way of notifying your button Click procedure that the
report did not open. Sometimes that is really useful to know, but if you
already popped up a MsgBox in the report's NoData event you may just want to
ignore this 2nd message.

Example of ignoring the error:

Private Sub cmdPrint_Click()
On Error Goto Err_Handler:

DoCmd.OpenReport "Report1"

Exit_Handler:
Exit sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & "L " & Err.Description
End If
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

Annoying errer message 1
no data on reports 2
No data event function 2
No data event 3
Access Reports crash on NoData event 2
NoData Event 4
Open Report Action Cancelled 1
Error 2501 4

Back
Top