Connecting Tech Pros Worldwide Forums | Help | Site Map

Pulling email addresses from a DB, then sending the email

Newbie
 
Join Date: Aug 2007
Posts: 30
#1: Nov 27 '07
I am working on a form for approval/disapproval of requests. Basically, the user will select a RequestID from a combobox, then select approve or disapprove, then hit the submit button. When they hit submit, I want to

1. Update the DB (which I have already implemented), then
2. using the RequestID, determine the two related email addresses (let's say Email1 and Email2) attached to the relevant ServiceID.

This sounds odd to me, but though I have done a good number of update queries, select queries to populate combo boxes, and a few other things, I haven't had to pull a particular field value from a query individually before and I'm not totally sure where to start.

I have no trouble putting together the actual SQL queries and everything, I'm just not sure how to manipulate the data to pull those two email addresses out individually.

JustJim's Avatar
Expert
 
Join Date: May 2007
Location: Bacchus Marsh, Victoria, Australia
Posts: 406
#2: Nov 28 '07

re: Pulling email addresses from a DB, then sending the email


Quote:

Originally Posted by Monroeski

I am working on a form for approval/disapproval of requests. Basically, the user will select a RequestID from a combobox, then select approve or disapprove, then hit the submit button. When they hit submit, I want to

1. Update the DB (which I have already implemented), then
2. using the RequestID, determine the two related email addresses (let's say Email1 and Email2) attached to the relevant ServiceID.

This sounds odd to me, but though I have done a good number of update queries, select queries to populate combo boxes, and a few other things, I haven't had to pull a particular field value from a query individually before and I'm not totally sure where to start.

I have no trouble putting together the actual SQL queries and everything, I'm just not sure how to manipulate the data to pull those two email addresses out individually.

Hi,
So your SQL would be something like
Expand|Select|Wrap|Line Numbers
  1. SELECT ServiceTable.Email1, ServiceTable.Email2
  2. FROM RequestTable INNER JOIN ServiceTable ON RequestTable.RequestID = ServiceTable.ServiceTableForeignKey
  3. WHERE RequestTable.RequestID = <the combo-box selection>
and you open a recordset (rs) based on that SQL

You then reference the Email addresses by
rs!Email1 and rs!Email2

And the bit you didn't ask, but is obvious from the title, you then use the SendObject method of the DoCmd object (watch the second-last option of the SendObject method, Edit or not edit, some network security settings get scared if you try to send email programatically without opening the email client.

Good luck and ask again if you need.

Jim
Newbie
 
Join Date: Aug 2007
Posts: 30
#3: Nov 29 '07

re: Pulling email addresses from a DB, then sending the email


Got it, thanks. I actually figured out a somewhat ridiculous workaround, but your way is better.

And I didn't mention about the SendObject method because I already had that part figured out. ; )
Reply