Email select page of report -- need help

S

sue gray

I am trying email a report to employees. I only want to email one page of
the report to each employee. Ex: John Doe gets john doe's page from the
report. I have messed with this code and can get it to use my query to send
email's with the report attached, but I can't figure out how to filter the
report. I need help. THanks in advance.

Option Compare Database

Private Sub Email_RPT_to_All_Emp_Click()
On Error GoTo Some_Err

Dim strBody As String, lngCount As Long, lngRSCount As Long
Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("All EmpTimeToDate_Crosstab")

lngRSCount = rst.RecordCount
If lngRSCount = 0 Then
MsgBox "No Reports to email.", vbInformation
Else

Do Until rst.EOF
lngRSCount = lngRSCount + 1
strTo = rst!EmailAddress

DoCmd.SendObject acSendReport, "All Emp Time", acFormatSNP, strTo, ,
, "Monthly Time", "Attached is your monthly time"

rst.MoveNext

Loop

End If
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
Close


MsgBox "Done sending Employee Time email. ", vbInformation, "Done"

Exit Sub

Some_Err:
MsgBox "Error (" & CStr(Err.Number) & ") " & Err.Description, _
vbExclamation, "Error!"


End Sub
 

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