Automatically populate fields in send object

C

CarlaInJax

I have a report that I e mail to people using the send object macro when the
user clicks a button. On this form I have several combo boxes. Is it
possible to have the send object automatically populate the TO: field from
one combo box selection and to have it automatically populate the SUBJECT:
field from another combo box selected?
 
A

Al Campagna

CarlaInJax,
Yes... just refer to the control names in the SendObject TO and SUBJECT
Arguments.
Example using just the To: and the Subject: arguments
Use your own object names...
DoCmd.SendObject , , , cboOne, , , cboTwo
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
C

CarlaInJax

When I populate the To: argument it is returning an error of "UNKNOWN MESSAGE
RECIPIENT(S); MESSAGE NOT SENT". If I remove the this argument and use just
the Subject: argument, it is populating the subject line with the
DoCmd.SendObject, , ,Nature of Complaint (which is the argument I've typed).
What am I doing wrong? I'm using the control source as shown in the
properties section of the form.

Thanks.
 
A

Al Campagna

CarlaInJax,
Sounds like the value (from the combo) for the TO argument is not a
legitimate email address (e-mail address removed)

First...
If you drop an argument in the SendObject method, you must leave it's
comma in the string... if... any other arguments follow.
Only after the last arugument can any remaing commas be dropped.
Also, if Nature of Complaint is the Subject... it should be a string,
in quotes.
DoCmd.SendObject , , , , , , "Your Subject"

Please make sure your combo box is truly delivering the value you want
in the TO argument.
To check a combo's value create a text control on the form with a
ControlSource of
= YouComboName

To test your SendObject TO, try the SendObject without the combo
value... just type in a real email address (your own would be fine) in the
TO argument.
DoCmd.SendObject , , , "(e-mail address removed)", , , "Subject"
Does that work?
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
C

CarlaInJax

It's still not working for me. I can get it to do the send object if I
manually type the e mail address in when it pops up in Outlook, or if I type
an e mail address as an argument, I just cannot get it to automatically
populate the fields for me. My fields with e mail addresses is called Work
Assigned To and the fields with the subject would be titled Nature of
Complaint. I've typed the following as arguments:

To: DoCmd.SendObject, , ,Work Assigned To
Subject: DoCmd.sendobject, , ,nature of complaint

What obvious thing am I overlooking?

Thanks.
 
A

Al Campagna

CarlaInJax,
OK, so it turns out that you're using the SendObject Action (in a macro)
instead of the SendObject Method (using VB) . Macros tend to be very
limited, and I've never used the SendObject "Action"
By using VB instead of a macro, you can avoid the extra "outlook prompt"
that occurs with a macro.

Try this instead...
You probably have a button on the form that you click to send the
email... let's say it's named "cmdSendEMail"
The combobox on the form that contains the Email address selection is
named [Work Assigned To]. (any object name that contains spaces must be
bracketed)

1. In the properties for the SendEmail button, find the OnClick
property, and put your cursor in the field.
2. Using the down arrow on the right of the text box, select (or
manually type in) [Event Procedure]
3. Now click the little button on the right with three dots (...)
You'll see this...

Private Sub cmdSendEMail_Click(Cancel As Integer)

End Sub

4. Now put your SendObject Method (see help on SendObject "Method")
between the two statements.

Private Sub cmdSendEMail_Click(Cancel As Integer)
DoCmd.SendObject , , , [Work Assigned To],,,"Nature of Complaint"
End Sub

When the SendEmail button is clicked... this will open your email
application with the TO filled in (with your email address from [Work
Assigned To]), and the Subject set to "Nature of Complaint".
Try it... you'll like it...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
C

CarlaInJax

Al,

YOU'RE MY HERO!!!

Thank you so very much for everything. You've been a great help.

Al Campagna said:
CarlaInJax,
OK, so it turns out that you're using the SendObject Action (in a macro)
instead of the SendObject Method (using VB) . Macros tend to be very
limited, and I've never used the SendObject "Action"
By using VB instead of a macro, you can avoid the extra "outlook prompt"
that occurs with a macro.

Try this instead...
You probably have a button on the form that you click to send the
email... let's say it's named "cmdSendEMail"
The combobox on the form that contains the Email address selection is
named [Work Assigned To]. (any object name that contains spaces must be
bracketed)

1. In the properties for the SendEmail button, find the OnClick
property, and put your cursor in the field.
2. Using the down arrow on the right of the text box, select (or
manually type in) [Event Procedure]
3. Now click the little button on the right with three dots (...)
You'll see this...

Private Sub cmdSendEMail_Click(Cancel As Integer)

End Sub

4. Now put your SendObject Method (see help on SendObject "Method")
between the two statements.

Private Sub cmdSendEMail_Click(Cancel As Integer)
DoCmd.SendObject , , , [Work Assigned To],,,"Nature of Complaint"
End Sub

When the SendEmail button is clicked... this will open your email
application with the TO filled in (with your email address from [Work
Assigned To]), and the Subject set to "Nature of Complaint".
Try it... you'll like it...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

CarlaInJax said:
It's still not working for me. I can get it to do the send object if I
manually type the e mail address in when it pops up in Outlook, or if I
type
an e mail address as an argument, I just cannot get it to automatically
populate the fields for me. My fields with e mail addresses is called
Work
Assigned To and the fields with the subject would be titled Nature of
Complaint. I've typed the following as arguments:

To: DoCmd.SendObject, , ,Work Assigned To
Subject: DoCmd.sendobject, , ,nature of complaint

What obvious thing am I overlooking?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top