andrew.abaye
New member
- Local time
- Today, 16:15
- Joined
- Jun 22, 2024
- Messages
- 14
Hello Folks,
I have created a form which allows me to print Access Report based on the criteria supplied on the combobox of the form which works fine. I have a second to email the report to the user and I have created a query which have the recipients email addresses. I expect the function to pick the email address of the recipient from the query and send the report. The function lunches outlook with the file in attachement but it does not pick the email address of the user from the file.
This is the code running on the Email button. I need help please.
Private Sub email_payslip_Click()
On Error Resume Next
Dim stDocName As String
Dim StaffEmail As String
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("qryemployeeEmail", dbOpenDynaset)
rs.MoveFirst
StaffEmail = rs(email)
stDocName = "EmployeePaySlip"
StaffID = Employeebox
Payserial = Payserialbox
Do
Employeebox = rs(employee_id)
Payserialbox = rs(PaYserialNumber)
'DoCmd.OpenReport stDocName, acPreview
DoCmd.SendObject acSendReport, stDocName, "PDFFormat(*.pdf)", StaffEmail, "", "", "Monthly PaySlip", "Kindly find your Monthly Payslip attached. Thank you.", False
rs.MoveNext
Loop Until rs.EOF
End Sub
I have created a form which allows me to print Access Report based on the criteria supplied on the combobox of the form which works fine. I have a second to email the report to the user and I have created a query which have the recipients email addresses. I expect the function to pick the email address of the recipient from the query and send the report. The function lunches outlook with the file in attachement but it does not pick the email address of the user from the file.
This is the code running on the Email button. I need help please.
Private Sub email_payslip_Click()
On Error Resume Next
Dim stDocName As String
Dim StaffEmail As String
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("qryemployeeEmail", dbOpenDynaset)
rs.MoveFirst
StaffEmail = rs(email)
stDocName = "EmployeePaySlip"
StaffID = Employeebox
Payserial = Payserialbox
Do
Employeebox = rs(employee_id)
Payserialbox = rs(PaYserialNumber)
'DoCmd.OpenReport stDocName, acPreview
DoCmd.SendObject acSendReport, stDocName, "PDFFormat(*.pdf)", StaffEmail, "", "", "Monthly PaySlip", "Kindly find your Monthly Payslip attached. Thank you.", False
rs.MoveNext
Loop Until rs.EOF
End Sub