SendObject - emailing reports

  • Thread starter Thread starter Heather
  • Start date Start date
H

Heather

Hi there,

I am trying to set up a macro to email a report to staff
but would prefer not to use a distribution list. Is there
a way that you can have the email sent to a staff member
whos staff id appears in the report itself...kind of like
a dynamic function.

Also, how can you prevent a blank report (no data) from
being sent to a recipient?

Thanks for your time...
H :-)
 
1. email addresss
I have set up a table with staff id and email address. I
added email address to the form and made the field not
visible. In the "TO" section of the macro I put
=[Forms]![NameOfForm]![NameOfTextbox]

2. No data cancel email
I got this from a previous post and it works well

'************* Code Start **************
** Put this on the NoData event in report

Private Sub Report_NoData(Cancel As Integer)

MsgBox "No data found! Closing report."

Cancel = True
End Sub

'************* Code End *************

will automatically close the report if there are no
records in the underlying source. However, if you're
opening the report from code behind a form, you need to
handle the error that's generated as a result.

'*********** Code Start ************

Private Sub TestNoData_Click()

On Error Resume Next ' change On errot to this - this
statement is all you need
DoCmd.OpenReport "SomeReport", acViewPreview
If Err = 2501 Then Err.Clear

End Sub

'*********** Code End ************

Jim
 
Back
Top