How can I distinguish between OpenReport 2501 errors?

M

Max Moor

Hi All,
If I understand correctly, I can get a 2501 error when I try to open a
report in a couple of ways...
opening a report that has no data, or
opening any report on a PC with no default printer

For all I know, there may be other cases. Is this correct? I suspect
it may not be, or why would there even be a NoData event for a report?
It seems that if a 2501 gets generated for a no data report, you'd never get
to the event in the first place.

Assuming I don't have this wrong in the first place, how can I
distinguish between the causes so I can display the correct cause in an error
message?

- Max
 
A

Allen Browne

There are other causes as well.

For example, you could cancel the Open event of the report.

Or if the report is taking some time to open, the user might cancel it
(Ctrl+Break.)

You might also want to see if the error is triggered if you cancel the
report before it finishes spooling to the printer driver (not merely before
it gets printed.)

In general, you don't care what triggered the error: you just know that the
report did not open, so you can't go on in your code and do stuff that
depends in it, such as referring to Reports!Report1.

If it's really important to know whether the error was triggered by the
NoData event, you could declare a public boolean variable, set it to False
before opening the report, and set it to True in the report's No Data event.
You can then test the variable to see whether the last OpenReport results in
the NoData cancelling it.
 
D

Douglas J. Steele

You haven't put any code in the NoData event, have you?

If you're closing the report in that event, then I believe that the 2501
error will still be raised in the calling routine. You can set a global
variable that the calling routine can check to see whether it was NoData
that generated the event.
 
M

Max Moor

You haven't put any code in the NoData event, have you?

If you're closing the report in that event, then I believe that the 2501
error will still be raised in the calling routine. You can set a global
variable that the calling routine can check to see whether it was NoData
that generated the event.

I do have code in the NoData event (in some cases). I don;t have it in the
one that started all this. So, if the 2501 error is raised, does the NoData
event still occur? It makes sense it would, or else why have it. Setting a
global would solve the issue. I really only want to know the difference
between a NoData and a "no printer" closure. Other cases, where the user
cancelled the report should be fairly evident. (Although they'll still be
politely captured by the error code.

Thanks guys!

Max
 

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