Capturing OnNoData error with ConvertReportToPDF

  • Thread starter Thread starter Leslie Isaacs
  • Start date Start date
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
 
You probably need to handle the problem in the ConvertReportToPDF function.
Or you need error trapping in in this function.
 
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
 
Back
Top