473,409 Members | 2,022 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

use sendobject to email selected recipients in listbox

Hi

I am helping my sister with an Access database someone wrote for her. I was wondering if someone a lot more knowledgeable than me, could provide some help and advice - I don't have that much experience with Accesss.

I helped her write (with assistance from others) the code to print the reports for her employees when they are selected from a list box. She has asked me if she can do the same so that instead of printing, it emails the reports as Access Snapshot attachments to the selected employees.

I have helped her email a report (using sendobject) for the Employee on screen, but she does not want to do that individually for her 25 employees, which is understandable.

For the printing of reports for selected employees from the list box, this is the code I have:

For Each EmployeeName In Me.EmployeeList.ItemsSelected
CurrentDb.Execute "INSERT INTO EmployeeTemp (EmployeeCode) VALUES (" & """" & Me.EmployeeList.ItemData(EmployeeN* ame) & """" & ")"
Next EmployeeName

DoCmd.OpenReport "ReportName", acNormal

Now, how can I email those reports for the employees selected in the list box?

I would appreciate any advice from anyone who has done this in Access.

Thanks - it's much appreciated
Oct 28 '06 #1
4 2601
pks00
280 Expert 100+
You have code that goes thru the selected items in the listbox
You then insert them into a temporary table, why is this. Does the report u run use this table?

Does your listbox store the email addresses? If so then that could make life easier for u. U can always hide that column

U have used SendObject so why not use your existing code and just expand on it a bit

What does your email use to split email addresses, do u use a semi colon or colon. No matter, what u can do is modify the code accordingly

U can add all email addresses in the one SendObject line
Oct 28 '06 #2
[quote=pks00]You have code that goes thru the selected items in the listbox
You then insert them into a temporary table, why is this. Does the report u run use this table? Does your listbox store the email addresses?
[/END QUOTE]

Hello,

Thanks for replying.

The report I run uses this temp table.

How can I change the following line so that it inserts both the employeecode and the employeeemail into the temporary table assuming the email address is in the listbox?

CurrentDb.Execute "INSERT INTO EmployeeTemp (EmployeeCode) VALUES (" & """" & Me.EmployeeList.ItemData(EmployeeN*ame) & """" & ")"

Thanks
Anthony
Oct 29 '06 #3
pks00
280 Expert 100+
Where is your email address currently held? if u store it in the listbox, then u can simply reference that
e.g.
your listbox contains

Employee Name in column 2 and Email Address in column 3 (amongst others)

Then in your loop, u go thru the selected items and reference that particular column

For Each iRow In Me.EmployeeList.ItemsSelected
CurrentDB.Execute "INSERT INTO EmployeeTemp (EmployeeCode, EmployeeEmail) VALUES ('" & Me.EmployeeList.Column(1, iRow) & "','" & Me.EmployeeList.Column(2, iRow) & "')"
Next iRow


Note, i used the variable iRow instead as it makes more sense
I reference

Me.EmployeeList.Column(1, iRow)

this refers the the 2nd column, - remember, column numbering starts from 0

1st col of data is column 0
2nd col of data is column 1

etc

do note, u must include the email address in the listbox in order to get at it, this means changing the rowsource
Oct 29 '06 #4
NeoPa
32,556 Expert Mod 16PB
How can I change the following line so that it inserts both the employeecode and the employeeemail into the temporary table assuming the email address is in the listbox?
Try something like :-

Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute "INSERT INTO EmployeeTemp
  2. (EmployeeCode, EmployeeEmail)
  3. VALUES ('" & Me.EmployeeList.ItemData(EmployeeName) & _
  4.     "','" & Me.EmployeeList.ItemData(EmployeeEmail) & "')"
INSERT INTO target [(field1[, field2[, ...]])]
VALUES (value1[, value2[, ...])
Oct 29 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RandyS | last post by:
I know how to do it in VB6, but that doesn't work in .NET. I am trying to select single or multiple items to load into a collection. -- ..NET Developer in Training
4
by: acni | last post by:
hey just wondering if anyone could offer a bit of advice to me.i have a database with a list of contacts on it with a checkbox beside each one.i was wondering if it was possible to place a...
1
by: xzzy | last post by:
how is the selected item set to selected in a listbox? I cannot get .SetSelected to work.
2
by: martin | last post by:
Hi, I am looking for a method to check if an item (any item) is selected in a particular listbox before deleteing it from my database, however I keep getting errors, The code I have is ...
0
by: Banu | last post by:
I have 2 listboxes, one with all application available, and the other with the selected applications by user (dual listbox). I have 3 tables (incident,application and ListApplication) ...
0
by: Banu | last post by:
I have 2 listboxes, one with all application available, and the other with the selected applications by user (dual listbox). I have 3 tables (incident,application and ListApplication) ...
2
by: Lazareth | last post by:
Hi, I am trying to write a program to send email messages to selected recipients on a form when a button is clicked (each recipient has a checkbox) . The recipient section I can work out, but I...
3
by: dragonfly8563 | last post by:
Hi all, I created a listbox with employees' names and email addresses in it, and a button which grabs email address once it's clicked. Currently I can only pick up one address at a time, but I...
7
by: ieda | last post by:
I want to display information when value in listbox selected. Below is my code:- This code to get value option in listbox <? $query = "select courseTitle from training where startDate > NOW()...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.