Hi,
I am trying to send separate Employees a PDF of their section/page of their report. The information is based on their EmployeeID. So each person has their balance information on a page then there's a page break, and then next page shows the next person's details. With the code below, it does email each of the employees one page but it so happens to only email the first person's page to EVERYONE. Is it possible to somehow automate so that each user is emailed his/her individual page of the report?
Another error is that the email pop up one by one so I have to press send each time for over 200 people, and that the email seems to be sending to the email but then followed by #mailto:the email# for example email@email.com#mailto:email@email.com#
I just started Access and have been copying and scraping code off of places I have found online. Many thanks in advance, if you can assist!
Have a great day!
- Option Compare Database
-
Option Explicit
-
-
Private Sub cmdSendAll_Click()
-
-
Dim rsAccountNumber As DAO.Recordset
-
Dim strTo As Variant
-
Dim strSubject As String
-
Dim strMessageText As String
-
-
Set rsAccountNumber = CurrentDb.OpenRecordset("SELECT DISTINCT EmployeeID, [email] FROM [queAutoUpdate]", dbOpenSnapshot)
-
-
Debug.Print strTo
-
-
With rsAccountNumber
-
-
Do Until .EOF
-
-
DoCmd.OpenReport "test", _
-
acViewPreview, _
-
WhereCondition:="EmployeeID = '" & !EmployeeID & "'", _
-
WindowMode:=acHidden
-
-
strTo = ![email]
-
strSubject = "Updated Balance "
-
strMessageText = "Text Here"
-
-
-
DoCmd.SendObject ObjectType:=acSendReport, _
-
ObjectName:="test", _
-
OutputFormat:=acFormatPDF, _
-
To:=strTo, _
-
Subject:=strSubject, _
-
MESSAGETEXT:=strMessageText, _
-
EditMessage:=True
-
-
-
DoCmd.Close acReport, "test", acSaveNo
-
-
-
.MoveNext
-
-
Loop
-
-
.Close
-
-
End With
-
End Sub