Send e-mail

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I have a simple database that is working pretty well for
the most part. The database replaces a form that was used
when a document needed to be reviewed, and also replaces
the form that was used to log the progress of the review.
In the database I select the reviewer's name from a combo
box (cboName) that has as its row source tblNames. The
name needs to be stored in tblMain. That works. Now I
would like to add a button next to the name to send the
reviewer an e-mail (to notify the reviewer that he or she
has been assigned to review the document, for instance).
Since the name has already been selected, it would be good
to be able to send the e-mail to that person. I could use
something like
DoCmd.SendObject acSendNoObject, , , Me![cboName], , , Me!
[Subject], "Message Body"
but that would place the person's name and not the e-mail
address into the e-mail message's To:. If the combo box's
underlying table (tblNames) had a field for e-mail
address, is there some way I could have the command button
place that rather than the bound column (the person's
name) into the To: field? Or is there an approach I am
not seeing? Main thing is I only want to select the name
once.
A related question: I have used this technique on another
form. It works well, unless you want to reconsider
sending the e-mail. If you cancel the e-mail, you get an
error message that the Send Object action was canceled. I
expect I need to add something to trap that error, but I
don't know how, or for that matter if I am using the
correct terminology.
 
You can access a specific column from a combo box control by referencing its
column property and specifying the number of the column you would like to
reference. The first column is 0, the second column is 1, and so on.

This is how your code would look like:
DoCmd.SendObject acSendNoObject, , , Me![cboName].Column(COLUMNNUMBERHERE),
, , Me!
[Subject], "Message Body"

Sal Rosario
Access Database Consultant
www.salrosario.com
 
Thanks. That worked perfectly for getting the e-mail
address into the To: field. The situation still exists
where if the user decides not to send the e-mail, and
instead closes it, there is an error stating that the
SendObject action has been cancelled. I want the users to
be able to just close the form.
I have a couple more questions. The purpose of the
database is to track and log document reviews. One of the
forms is to view just the open (not yet completed)
reviews. The form is based on a query (qryOpenReviews).
There is a button on the form to preview the report that
is based on the current record. When there are no open
reviews, clicking the preview button causes an error
messag. I would like to disable the button when the query
returns zero records.
Next, I would like for the users to be able to modify only
certain fields. I know I can protect the entire record,
but the whole point is for several reviewers to be able to
add comments.
Finally, I have a custom menu bar attached to the startup
form, at the On Open event, thus:
DoCmd.ShowToolbar "Custom Menu", acToolbarNo
DoCmd.Maximize
Everything looked fine when I started the DB, but when I
viewed a report, then closed it, the custom menu bar from
the report would be a part of the startup screen. To keep
that from happening I put the above code into the form's
On Activate event. Was that the best choice?
-----Original Message-----
You can access a specific column from a combo box control by referencing its
column property and specifying the number of the column you would like to
reference. The first column is 0, the second column is 1, and so on.

This is how your code would look like:
DoCmd.SendObject acSendNoObject, , , Me![cboName].Column (COLUMNNUMBERHERE),
, , Me!
[Subject], "Message Body"

Sal Rosario
Access Database Consultant
www.salrosario.com

I have a simple database that is working pretty well for
the most part. The database replaces a form that was used
when a document needed to be reviewed, and also replaces
the form that was used to log the progress of the review.
In the database I select the reviewer's name from a combo
box (cboName) that has as its row source tblNames. The
name needs to be stored in tblMain. That works. Now I
would like to add a button next to the name to send the
reviewer an e-mail (to notify the reviewer that he or she
has been assigned to review the document, for instance).
Since the name has already been selected, it would be good
to be able to send the e-mail to that person. I could use
something like
DoCmd.SendObject acSendNoObject, , , Me![cboName], , , Me!
[Subject], "Message Body"
but that would place the person's name and not the e- mail
address into the e-mail message's To:. If the combo box's
underlying table (tblNames) had a field for e-mail
address, is there some way I could have the command button
place that rather than the bound column (the person's
name) into the To: field? Or is there an approach I am
not seeing? Main thing is I only want to select the name
once.
A related question: I have used this technique on another
form. It works well, unless you want to reconsider
sending the e-mail. If you cancel the e-mail, you get an
error message that the Send Object action was canceled. I
expect I need to add something to trap that error, but I
don't know how, or for that matter if I am using the
correct terminology.


.
 
Back
Top