Report Operations - Mail Report Query Design - Modify with VBA (1 Viewer)

trele6

New member
Local time
Today, 11:12
Joined
Jul 4, 2016
Messages
2
Hello all,

I would say I am a bad intermediate level database person when it comes to VBA code (I'm self taught from the internet).

I have a payroll database and we want to create a docmd that will automatically email payslips to each employee. One email/ One Pdf per employee

I've used the design wizard in Access 2013 report options for a mail report but it will not autopopulate the email address when it opens outlook.

The default code is:

Code:
Option Compare Database
 Private Sub cmdSendEMail_Click()
Call SendMyEmail
End Sub
Private Sub Mail_Report_Click()
On Error GoTo Err_Mail_Report_Click
     Dim stDocName As String
    
    stDocName = "PayrollPayslipSingle"
    DoCmd.SendObject acReport
         
Exit_Mail_Report_Click:
    Exit Sub
 Err_Mail_Report_Click:
    MsgBox Err.Description
    Resume Exit_Mail_Report_Click

Could anyone suggest a way to change this code to auto populate an email address that is shown on the form where the command button is placed?

My form(PayslipSingle) shows employee number (EmplNo), name(EmplName), and email address (txtemail) as separate fields. Data is pulled from my table named Employees, and it is shown on my report named PayrollPayslipSingle.

This process would take me manually pushing the button about 400+ times as that is how many employees we have. As a stretch goal I was wondering if it is possible to code a macro that would run this process through the whole table of employees sending one email to each for only one button click???

Appreciate any help I can get, again I apologize as I am no expert on VBA.
 
Last edited:

trele6

New member
Local time
Today, 11:12
Joined
Jul 4, 2016
Messages
2
See this blog on my website. might give you some ideas:-

Gizmo, I appreciate the link, and I watched the video's, not sure if I am at a level high enough to perform what you were doing. I'm not familiar with a lot of the VBA code you used.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:12
Joined
Aug 30, 2003
Messages
36,118
Along the lines of:

DoCmd.SendObject acReport ,"PayrollPayslipSingle",,Me.txtemail
 

Users who are viewing this thread

Top Bottom