Cancel = True

S

Stapes

Hi

I am attempting to run the following code: -

Dim stDocName As String

stDocName = "KPI Data - New links to PEOPLE table"
DoCmd.OpenReport stDocName, acPreview
stDocName = "KPI Data - New ATTEND Records"
DoCmd.OpenReport stDocName, acPreview

Both reports have On No Data property set. They display a brief
message, and set Cancel to True. Trouble is, once this happens on the
first report, it doesn't even try to open the second report. I presume
this is because Cancel is set to true. If this is the case, how do I
correct it?

Stapes
 
A

Allen Browne

Use Error handling to resume after error 2501.

In this particular case, you could just add this line to the top of your
procedure:
On Error Resume Next

However, that really makes the code hard to debug. If it fails for any
reason (e.g. the report is misspelled), you don't hear about it. Better to
use error handling as described here:
http://allenbrowne.com/ser-23a.html
 

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