Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-07-2019, 05:14 AM   #1
CresolZim
Newly Registered User
 
Join Date: Mar 2019
Location: Zimbabwe
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
CresolZim is on a distinguished road
Emailing multiple payslips to several employees at once

I have developed a payroll program in Access . I have the payslip report based on a query.Each employee table has an email field. Using the Sendobject Im able to send emails to each employee individually. I need Assistance for a procedure that will allow a individual payslips to be sent to several individual employees on one click.

CresolZim is offline   Reply With Quote
Old 08-07-2019, 05:23 AM   #2
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 7,992
Thanks: 64
Thanked 2,545 Times in 2,444 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Emailing multiple payslips to several employees at once

use recordset:
Code:
With Currentdb.Openrecordset("employeeTableName", dbopensnapshot)
    .MoveFirst
    While Not .EOF
        docmd.SendObject  To:=!email_adrress_Field
        .MoveNext
    Wend
End With
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 08-07-2019, 07:23 AM   #3
CresolZim
Newly Registered User
 
Join Date: Mar 2019
Location: Zimbabwe
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
CresolZim is on a distinguished road
Re: Emailing multiple payslips to several employees at once

Thank You for Your Advice and code. Ive tested the code on a sample but the email has blanks.
This is my sample code:
Private Sub Command0_Click()
Dim DBSEmailSample As Database
Dim rstPayslips As Recordset
Dim prploop As Property
Dim Y As String
Set DBSEmailSample = OpenDatabase("emailSample.accdb")
Set rstPayslips = DBSEmailSample.OpenRecordset("QryRep", dbOpenSnapshot)
Y = rstPayslips!Email
With CurrentDb.OpenRecordset("QryRep", dbOpenSnapshot)
.MoveFirst
While Not .EOF
DoCmd.SendObject , Y
.MoveNext
Wend
End With

End Sub

CresolZim is offline   Reply With Quote
Old 08-07-2019, 08:46 AM   #4
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 7,992
Thanks: 64
Thanked 2,545 Times in 2,444 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Emailing multiple payslips to several employees at once

Code:
Private Sub Command0_Click()
    Dim DBSEmailSample As dao.Database
    Dim rstPayslips As dao.Recordset
    Dim prploop As Property
    Dim Y As String
    Set DBSEmailSample = OpenDatabase("emailSample.accdb")
    Set rstPayslips = DBSEmailSample.OpenRecordset("QryRep", dbOpenSnapshot)
    With rstPayslips
        If Not (.BOF And .EOF) Then .MoveFirst
        While Not .EOF
            Y = rstPayslips!Email
            DoCmd.SendObject To:=Y, Subject:="Payslip", MessageText:="Your payslip for this month", _
                            Objecttype:=acSendReport, ObjectName:="theNameOfReport", OutputFormat:=acFormatPDF
            .MoveNext
        Wend
        .Close
    End With
    Set rstPayslips = Nothing
    Set DBSEmailSample = Nothing
End Sub
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 08-08-2019, 02:25 AM   #5
CresolZim
Newly Registered User
 
Join Date: Mar 2019
Location: Zimbabwe
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
CresolZim is on a distinguished road
Re: Emailing multiple payslips to several employees at once

Thank you. The code Works. The only snag is that the payslip Report has the payslips for all the employees. And this is sent to each employee , and thats not a good idea.

I have a procedure for selecting individual employees but this is not appropriate as I have to send each individual payslip one at a time.
The other problem is that the code only moves to movenext after I have pressed the send button in outlook.If Im sending 40 payslips I want to press send Once.
I appreciate your assistance and patiance
CresolZim is offline   Reply With Quote
Old 08-08-2019, 02:30 AM   #6
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 7,992
Thanks: 64
Thanked 2,545 Times in 2,444 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Emailing multiple payslips to several employees at once

if outlook is stalling the code. you could try to use Outlook automation on sending mail, rather than using SendObject.
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 08-08-2019, 04:13 AM   #7
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 10,227
Thanks: 513
Thanked 917 Times in 869 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: Emailing multiple payslips to several employees at once

In this Blog on Nifty Access:-

https://www.niftyaccess.com/generate-multiple-reports/


I demonstrate a method of creating a single report from a set. Basically you have a template report, to which you send an SQL string which controls what is displayed on the Report.

The SQL string is created by two recordset loops, one loop extracts each users details and the other extracts the particular record details related to that user. In your case, the payslip details.

If you want some help adapting it to your situation I'm available this weekend.





Sent from my Pixel 3a using Tapatalk

__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|                                     |
|                                     |
| Get $20 worth of "Nifty Code"       |
|      
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)
Uncle Gizmo is offline   Reply With Quote
Old 08-09-2019, 07:09 AM   #8
CresolZim
Newly Registered User
 
Join Date: Mar 2019
Location: Zimbabwe
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
CresolZim is on a distinguished road
Re: Emailing multiple payslips to several employees at once

I think something like that will give me the results I want.What do I need to do to get more details
CresolZim is offline   Reply With Quote
Old 08-09-2019, 11:40 AM   #9
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 10,227
Thanks: 513
Thanked 917 Times in 869 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: Emailing multiple payslips to several employees at once

Quote:
Originally Posted by CresolZim View Post
I think something like that will give me the results I want.What do I need to do to get more details
Assuming you are referring to my post, have you looked at the information on the Nifty Access website?

Please note the Access example file can be downloaded from here:-

https://sellfy.com/p/tZxO/

To get it for free, use Coupon Code:- NAFreeUXKCJ

__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|                                     |
|                                     |
| Get $20 worth of "Nifty Code"       |
|      
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)

Last edited by Uncle Gizmo; 08-09-2019 at 11:47 AM.
Uncle Gizmo is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Employees Per Client milkman2500 Tables 2 11-08-2012 11:33 PM
One project, multiple employees - one query result. rclarke Queries 20 10-31-2012 06:56 AM
Weekly Data for Multiple Projects with Multiple Employees Working on Projects dataCrazy Tables 35 06-27-2010 06:21 PM
Help w/ Multiple Employees into 1 Table? eyal8r Queries 1 09-05-2007 12:13 PM
Active Employees/Inactive Employees desireemm General 2 01-14-2004 11:49 AM




All times are GMT -8. The time now is 07:53 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World