Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Suppress popup warning for no data

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2005-08-22 : 09:57:28
I have a batch print out job on a backend server. The app prints out Access Reports. In order to run it unattended, I need to suppress a popup message.

The popup was err 2501: The PrintOut action was Canceled, caused by
Report_NoData for certain page of the report in question.

I tried to trap the err in the following way, but it did not work.

Private Sub Report_NoDate(Cancel as integer)
Beep
Cancel=true
End Sub

Sub PrintReport()
On err goto errHandle:
...
DoCmd.PrintOut
...
errHandle:
If err.number =2501 then
resume next
end if
This is not working because when there is not data, DoCmd made the popup shows, the errHandle never got a chance to catch it.

I also tried to eliminate the no data record from the underlying query without any luck. Because when the query first runs, there is data. However, during the long looping batch, some of the records got processed by other transactions and the data no longer there.

Any idea how I can suppress the popup programmatically so I don't have to sit in the closet all day long clicking OK when the batch is running?

Thanks for the rescue!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-08-22 : 10:14:00
It is hard to tell what is wrong with your code when you only give us snippets of it ....

The line of code that opens your report is the one that you need to trap for error handling, not the PrintOut line. The error will occur before the printOut statement.

All you need to do to open a report + print it out in 1 line is:

docmd.openreport "report name", acViewNormal

which will send the report directly to the printer, w/o needing a separate Docmd.PrintOut statement. Trap that statement for error 2501 and you should be good to go.
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2005-08-22 : 10:28:01
I don't have a line to open the report. I guess I could try to add that line there.

When I debug it, I saw the popup only after I stepped into the PrintOut line. Maybe I should set more break points before that.

Thanks!
Go to Top of Page
   

- Advertisement -