Hello freakazeud
Really appreciate the effort you and BruceM are putting in.
Unfortunately, however, I have not yet cracked it....
I deleted my old buttons and have created a new button with only the
following code:
Private Sub cmdNotify_Click()
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String
strSubject = "adamstest"
strToWhom = Me.email.Column(2)
strMsgBody = "adamstestcontent"
DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True
End Sub
My comboSource has a Data Control Source entitled 'email'. I created
three
columns in my table with those values and the email address is in the
3rd
one
(i.e. Column2).
I have saved this and selected my email, pressed the button...and
nothing
happens....
I tried also changing 'email' to the Name of the contact email combo
box
but
this didn't seem to work either. I feel I am pretty close thanks to
your
help
but just can't quite get it....
Cheers,
Adam
:
Hi,
Forms/reports hold controls...fields are in tables, so you want to
reference
a bound contorl which holds the value. It doesn't really matter what
this
control is textbox/combo...the only difference is that refering to the
default value property of comboboxes will return the bound column
value.
If
the email is in that one then you are fine...if not then you need to
reference the correct column. The column count is zero based so
refering
to
the second column would be:
Me.YourCombo.Column(1)
So you can have the actual email in the second column and an alias in
the
first column which is the only one displayed (specify the column width
in
the
combobox format properties).
To add the email code open your form in design view...open the
button's
property dialog. Go to the event tab and browse for the on click
event.
Select [event procedure] from the drop down list and click the "..."
next
to
it. This will open the VBA editor with a preformatted on click routine
for
you. Add the SendObject code in between the beginning and end of the
procedure. In the 'To' argument of the sendobject code refernce the
combobox
(either its default value property or some specific column) as
somewhat
described earlier in the small sample. Close the editor...open form in
form
view...select something in the combo...press the button and see what
happens
You just have written your first custom VBA procedure.
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps -
http://www.oli-s.de
:
Hi freakazeud and thanks for your response.
I think the answer is yes...On the control source entry for the data
tab of
my email field properties, 'email' (no quotes) is specified.
What I want to do ultimately is have a combo box which has the email
address
of different partner organizations. Selecting one and clicking the
send
email
button would send the message specified to the email address. Also,
I
was
hoping to not actually display the full address in the dropdown men
but
a
representation of it, so for example - nike = (e-mail address removed),
adidas =
(e-mail address removed) etc...
However, I was hoping to first get my databse to read whatever was
in
the
email field and work things out from there.
I'm a bit wary of using visual basic as I've never used it before
nor
done
any programming - however, if you think it's the best way to go,
I'll
certainly give it a go. Without using macros, could I achieve this
in
the
expression builder, do you think?
Thanks again for your kind help.
Adam
:
Hi,
do you have a control on the form where this action is being
executed
which
is bound to the email table field? If so then you need to
reference
it
correctly.
I would suggest you do not use macros...they are very limited and
cannot
handle error handling (at least not yet). Within VBA you can
similarly use
the Sendobject method and just reference the form control which
holds
the
email value e.g.:
Dim strToWhom As String
Dim strMsgBody As String
Dim strSubject As String
strSubject = "Your Subject"
strToWhom = Me.YourControl 'referencing the form control which
holds
the
email address
strMsgBody = "Your Body text goes here!"
DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True
HTH
Good luck
--
Oli-S
Admin Specialist & Computer Science Major @ UMD - Go Terps -
http://www.oli-s.de
:
Hello all,
I have created a button called 'Notify person' on a form. The
purpose of
this button is to notify a member of staff when an entry into a
table has
been made against his / her name.
I have attempted to do this as follows.
In the properties tab of my button, on the event tab, at the On
click option
I have created a Macro.
I have selected the SendObject command.
I wish to send the email to the address of the person whose name
features in
a field which I have created on my table, entitled 'email'. As
such
in the
'to' column of the action arguments (in the macro) I have
entered
This however, does not work and I receive the message (unknown
message
recipient, the message was not sent).
I guess I'm just not specifying the field properly, but
essentially
I want
to send the email to whatever address is specified in the 'to'
column.
Many thanks in advance.
Adam
[/QUOTE]
[/QUOTE][/QUOTE]