report has data?

K

Karen

Hi there,

I have a list of companies in a table ([Companies]) who I
want to email a report to (well actually 3 reports, but I
won't worry about that now).

I was thinking I would go through the table, looping a
procedure to generate the report (with appropriate company
filter) and sending off the emails 1 at a time.

Is there a way that I can identify if the report is going
to come out empty (no data), and as a result to not send
the email? How if so?

Thank you all,

Karen
 
J

Jim/Chris

I got this code from one of the valuable MVP's. I use it
and it will not do the sendobject in a macro if the report
has no data

___________________________________
Code the report's OnNoData event:
MsgBox "No records to show."
Cancel = True

This will give you an error if you opened the report from a
form event.
Code the form command button event:

On Error GoTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview

Exit_This_Sub:
Exit Sub

Err_Handler:
If Err = 2501 then
Else
MsgBox "Error #: " & Err.number
End If
Resume Exit_This_Sub
________________________________________
Good Luck

Jim
 

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