email report (1 Viewer)

Gismo

Registered User.
Local time
Today, 04:26
Joined
Jun 12, 2017
Messages
1,298
Hi all,

How do I email a report in Access 2016 based on the users table where specific users have a tick to receive that report?
 

Ranman256

Well-known member
Local time
Yesterday, 21:26
Joined
Apr 9, 2015
Messages
4,337
make a query to pull only the names of the ticked emails.

on the form, put a listbox, (lstBox),bound to this query. The list shows the emails from the query to send to.

now click a Send button that cycles thru the list ,sending the report.

Code:
'send the emails
sub btnSend_click()
dim vTo, vSubj, vBody
dim i as integer

for i = 0 to lstBox.listcount -1
    vTo = lstBox.itemdata(i)    'get next item in listbox
    lstBox = vTo		'set the listbox to this item

        'get rest of info from form
    vSub = txtSubj
    vBody = txtBody

   docmd.SendObject acSendReport ,txtReport,acFormatPDF,vTo,,,vSubj,vBody
next
end sub

you could also add a combo box to select which report to send them.
 

Gismo

Registered User.
Local time
Today, 04:26
Joined
Jun 12, 2017
Messages
1,298
tnx, just a few changes, I already have a button on a form to which runs a few queries , how do I change the code to run from a macro instead of directly from a button which has underlying macro commands?
 

Users who are viewing this thread

Top Bottom