This is one of those probelms that I really thought I could solve myself.
I have to admit that I am stumped.
I have a button on my main form called "TestForm" with a record source from a query named "MonthlyPaymentDue".
On my form is a button that when pressed executes a loop.
I want the loop to send an email to each recipient with an attached report specific to them.
The report has a text box named "PlayerName" that references the text box "TextID" on my main form called "TestForm".
The loop seems to be working in that the loop does send an email to each recipient but the report that is attached is not specific to them.
The report that is emailed to everyone is the very first recipients report.
I have tried to use the DoCmd.GoToRecord , , acNext. to go to the next record on my main form but this isn't working.
Here is my code.
If anyone can help this would save me many hours of future invoicing.
Thank you.
I have to admit that I am stumped.
I have a button on my main form called "TestForm" with a record source from a query named "MonthlyPaymentDue".
On my form is a button that when pressed executes a loop.
I want the loop to send an email to each recipient with an attached report specific to them.
The report has a text box named "PlayerName" that references the text box "TextID" on my main form called "TestForm".
The loop seems to be working in that the loop does send an email to each recipient but the report that is attached is not specific to them.
The report that is emailed to everyone is the very first recipients report.
I have tried to use the DoCmd.GoToRecord , , acNext. to go to the next record on my main form but this isn't working.
Here is my code.
Code:
Private Sub Click_Click()
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("MonthlyPaymentDue", dbOpenSnapshot)
Do Until rsEmail.EOF
sToName = rsEmail!PlayerEmail
sSubject = "Invoice." & " " & rsEmail!PlayerName
sMessageBody = "Hello" & " " & rsEmail!PlayerName
DoCmd.SendObject acSendReport, "StatementOnePlayerAuto", acFormatPDF, sToName, , , sSubject, sMessageBody, False, False
DoCmd.GoToRecord , , acNext
rsEmail.MoveNext
Loop
Set MyDb = Nothing
Set rsEmail = Nothing
End Sub
Thank you.