Close Report and Cancel if there are no records.

  • Thread starter Thread starter Carl Mankat
  • Start date Start date
C

Carl Mankat

I found how to do this for forms using RecordsetClone.RecordCount = 0
and using Cancel = True.

How can I do the same thing for a form?

TIA,

Carl
 
Carl said:
I found how to do this for forms using RecordsetClone.RecordCount = 0
and using Cancel = True.

How can I do the same thing for a form?


For a report, use the NoData event:

Cancel = True

The report will not display, but you will get an action was
cancelled message. If you opened the report from VBA code
in a form's event procedure, you can trap error 2501 and
ignore the error. If you need help with this, post the form
procedure that opens the report.
 
Thanks, I tried that and it gave me what I was after. Will Access Help
give me anything about Cancel?

TIA, again,

Carl
 
Cancel is mentioned in the NoData Event topic in A03, but it
doesn't say any more than setting it to True prevents the
report from printing.

If that's all you do, pretty soon you will notice the pop up
message. Most people don't want to see this so I Suggested
the way to suppress the message.
 
Back
Top