Capturing OnNoData error with ConvertReportToPDF

L

Leslie Isaacs

Hello All

I have lot of statements similar to the following:

rptname = "rpt monthly summary letter"
flname = mth & "-Payroll-Covering letter"
blret = ConvertReportToPDF(rptname, vbNullString, drname & flname &
".pdf", False)

Each statement uses a different report.
For each report I have the 'OnNoData' event set to Cancel = True, but I want
to prevent the error message from being displayed when there is no data for
a report. When the report is generated by clicking a button I can add
If Err = 2501 Then Err.Clear
to the OnClck event of the button, and this prevents the message from being
displayed, but the same thing doesn't work where the report is generated by
the above code. Is there another way of preventing the error message from
being displayed when there is no data for a report?

I hope someone can help.

Many thanks
Les
 
J

John Spencer

You probably need to handle the problem in the ConvertReportToPDF function.
Or you need error trapping in in this function.
 
T

td

A very easy way is to wrap it between two lines
On error resume next
blret = ConvertReportToPDF(rptname, vbNullString, drname & flname & ".pdf",
False)
On error got 0

Trouble is it also supresses other errors
td
 

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