doucet1963
Registered User.
- Local time
- Yesterday, 21:06
- Joined
- Feb 4, 2017
- Messages
- 18
I have this code that works except that it generates an email with everyone's name that are in the table. What I need, is to adapt the code so it would send an email to the names that are in the opened report using an action button.
The code is:
I need to find a solution to replace the statement
Set rst = CurrentDb.OpenRecordset("TableXXX")
so the email addresses would come from the report named "Rep_Assigned_Authority"
Thanks
PS> Sorry if the format is incorrect I am still learning...
The code is:
Code:
Private Sub Generate_Email_Click()
Dim rst As DAO.Recordset
Dim strEmailAddress
On Error GoTo ErrorHandler
Set rst = CurrentDb.OpenRecordset("Tbl_Organization_Contacts")
Do Until rst.EOF
If Len(rst("Email") & vbNullString) <> 0 Then strEmailAddress = strEmailAddress & rst("Email") & ","
rst.MoveNext
Loop
strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)
DoCmd.SendObject acSendReport, "Rep_assigned_Authority", acFormatPDF, strEmailAddress, _
, , "Assignement of Authority", , True
rst.Close
Set rst = Nothing
ErrorHandler:
Select Case 16388
Case 16388
MsgBox ("The email was not sent")
Case Else
End Select
End Sub
I need to find a solution to replace the statement
Set rst = CurrentDb.OpenRecordset("TableXXX")
so the email addresses would come from the report named "Rep_Assigned_Authority"
Thanks
PS> Sorry if the format is incorrect I am still learning...