E-mail from a record on a form

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

Bruce

I have been searching newgroups for an answer to what
should be a simple question, but is not if the variety of
replies to the question is any indication. I have a form
that displays a record about a customer. I would like to
add a command button to send a blank e-mail to that
customer. The control button is named "cmdSendEmail".
The text box on the form containing the e-mail address is
named "strContactEmail". I can send an entirely blank e-
mail, and I can e-mail a database object, but I cannot
find a way to send a blank e-mail to that particular
customer.
A caveat: Instructions such as "Put this code behind the
command button" or anything else that assumes I know how
to add code will be a waste of your valuable time, as I
will not know what you mean. I need something that
says "Right click the command button to view its property
sheet. Click "On Click", then click the down arrow to
see "Event Procedure", then click the three dots to
see...", etc.
A further question: The Event Procedure seems to be
heading me in the right direction, so I will ask more
about it. There is an Expression Builder, a Code Builder,
and a Macro Builder. Which do I need, and when? Most
instructions on this matter make some reference to
building an action, which does not seem to be described as
such in Help documentation.
I know this is a lot to ask. If it is too much for this
forum, please point me to a reference web site or to a
reference book. Thanks in advance for any assistance.
 
Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box, strContactEmail, is
bound should be a Text type field - not a Hyperlink type field.

Here is how to get the code behind the command button:

In your form's design view, right-click on your command button, then select
Properties from the pop-up menu. In the properties sheet for that command
button, find the Click event and click anywhere on that line. You will see
a downward pointing arrow at the right edge of the line. Click it and
select Event Procedure. Then, look for the small button to the right of the
downward pointing arrow which contains an ellipsis (three dots ...). Click
this button to open the code window for the Click event.

When the code window is first opened, it will look like this:

Private Sub cmdSendEmail_Click(Cancel As Integer)

End Sub

You will want to insert the following lines after the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the Save button. Then,
from the menu, click Debug and select Compile. Close the code window; save
your form and return it to form view.
 
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank when
it opened (nothing in the To field). Outlook 2000 is the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration does not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the name
of a user-defined function, or [Event Procedure]. *There
may have been an error evaluating the function, event, or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update, which is
a drop down list of vendors. Clicking the appropiate name
places all vendor information into the appropriate fields
on the form. When the command button was in place, the
drop down list did not return the appropriate information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to shed
on this.
 
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just ().

My apologies - just leave the procedure header as it is - do not add
anything
The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String" are in blue; the
variable name is in black.
The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the Bound Control Name the
same as the underlying Field/Query Name, most developers find it helpful to
do so. Opinion: Many (possibly most?) developers do not "pre-pend" field
names with type qualifiers such as "str" or "int" but reserve that
convention for variable naming. Later on (if you have not looked at the
database for a while) or in applications with lots of code, it is much
easier to differentiate variables from fields this way. However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Bruce said:
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank when
it opened (nothing in the To field). Outlook 2000 is the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration does not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the name
of a user-defined function, or [Event Procedure]. *There
may have been an error evaluating the function, event, or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update, which is
a drop down list of vendors. Clicking the appropiate name
places all vendor information into the appropriate fields
on the form. When the command button was in place, the
drop down list did not return the appropriate information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box, strContactEmail, is
bound should be a Text type field - not a Hyperlink type field.

Here is how to get the code behind the command button:

In your form's design view, right-click on your command button, then select
Properties from the pop-up menu. In the properties sheet for that command
button, find the Click event and click anywhere on that line. You will see
a downward pointing arrow at the right edge of the line. Click it and
select Event Procedure. Then, look for the small button to the right of the
downward pointing arrow which contains an ellipsis (three dots ...). Click
this button to open the code window for the Click event.

When the code window is first opened, it will look like this:

Private Sub cmdSendEmail_Click(Cancel As Integer)

End Sub

You will want to insert the following lines after the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the Save button. Then,
from the menu, click Debug and select Compile. Close the code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX




.
 
This is the code in its entirety:

Private Sub cmdEmailToContact_Click()

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink ADDRESS:=strEmail

End Sub

The name of the field is now ContactEmail (I started with
it as Contact Email, but the space seemed to create
problems. The error message "Expected: End of statement"
or something like that went away when I enclosed Contact
Email in square brackets (which I thought was the system
for field names), but it made no difference. Nor does it
make a difference if I enclose ContactEmail in square
brackets. The command button opens a blank e-mail.
-----Original Message-----
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just ().

My apologies - just leave the procedure header as it is - do not add
anything
The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String" are in blue; the
variable name is in black.
The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the Bound Control Name the
same as the underlying Field/Query Name, most developers find it helpful to
do so. Opinion: Many (possibly most?) developers do not "pre-pend" field
names with type qualifiers such as "str" or "int" but reserve that
convention for variable naming. Later on (if you have not looked at the
database for a while) or in applications with lots of code, it is much
easier to differentiate variables from fields this way. However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank when
it opened (nothing in the To field). Outlook 2000 is the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration does not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the name
of a user-defined function, or [Event Procedure]. *There
may have been an error evaluating the function, event, or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update, which is
a drop down list of vendors. Clicking the appropiate name
places all vendor information into the appropriate fields
on the form. When the command button was in place, the
drop down list did not return the appropriate information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box, strContactEmail, is
bound should be a Text type field - not a Hyperlink
type
field.
Here is how to get the code behind the command button:

In your form's design view, right-click on your command button, then select
Properties from the pop-up menu. In the properties
sheet
for that command
button, find the Click event and click anywhere on that line. You will see
a downward pointing arrow at the right edge of the line. Click it and
select Event Procedure. Then, look for the small
button
to the right of the
downward pointing arrow which contains an ellipsis
(three
dots ...). Click
this button to open the code window for the Click event.

When the code window is first opened, it will look like this:

Private Sub cmdSendEmail_Click(Cancel As Integer)

End Sub

You will want to insert the following lines after the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the
Save
button. Then,
from the menu, click Debug and select Compile. Close
the
code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX

I have been searching newgroups for an answer to what
should be a simple question, but is not if the
variety
of
replies to the question is any indication. I have a form
that displays a record about a customer. I would
like
to
add a command button to send a blank e-mail to that
customer. The control button is named "cmdSendEmail".
The text box on the form containing the e-mail
address
is
named "strContactEmail". I can send an entirely
blank
e-
mail, and I can e-mail a database object, but I cannot
find a way to send a blank e-mail to that particular
customer.
A caveat: Instructions such as "Put this code behind the
command button" or anything else that assumes I know how
to add code will be a waste of your valuable time, as I
will not know what you mean. I need something that
says "Right click the command button to view its property
sheet. Click "On Click", then click the down arrow to
see "Event Procedure", then click the three dots to
see...", etc.
A further question: The Event Procedure seems to be
heading me in the right direction, so I will ask more
about it. There is an Expression Builder, a Code Builder,
and a Macro Builder. Which do I need, and when? Most
instructions on this matter make some reference to
building an action, which does not seem to be
described
as
such in Help documentation.
I know this is a lot to ask. If it is too much for this
forum, please point me to a reference web site or to a
reference book. Thanks in advance for any assistance.


.


.
 
OK. Let's go back to your original post, in which you said: "I have a form
that displays a record about a customer. I would like to
add a command button to send a blank e-mail to that customer."

I interpreted this to mean: Your form contains a control containing an
email address for that customer. You want some code that will open your
default email program, filling the To: portion of the email window with the
customer's email address. Was that correct? If not, please provide more
detail.

Skip to the current result:

You have the following code behind a command button on your form:

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink Address:=strEmail

but, when you click that button, your default email program opens with no
email address in the To: portion of the email window. Is that correct?





--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Bruce said:
This is the code in its entirety:

Private Sub cmdEmailToContact_Click()

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink ADDRESS:=strEmail

End Sub

The name of the field is now ContactEmail (I started with
it as Contact Email, but the space seemed to create
problems. The error message "Expected: End of statement"
or something like that went away when I enclosed Contact
Email in square brackets (which I thought was the system
for field names), but it made no difference. Nor does it
make a difference if I enclose ContactEmail in square
brackets. The command button opens a blank e-mail.
-----Original Message-----
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just ().

My apologies - just leave the procedure header as it is - do not add
anything
The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String" are in blue; the
variable name is in black.
The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the Bound Control Name the
same as the underlying Field/Query Name, most developers find it helpful to
do so. Opinion: Many (possibly most?) developers do not "pre-pend" field
names with type qualifiers such as "str" or "int" but reserve that
convention for variable naming. Later on (if you have not looked at the
database for a while) or in applications with lots of code, it is much
easier to differentiate variables from fields this way. However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank when
it opened (nothing in the To field). Outlook 2000 is the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration does not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the name
of a user-defined function, or [Event Procedure]. *There
may have been an error evaluating the function, event, or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update, which is
a drop down list of vendors. Clicking the appropiate name
places all vendor information into the appropriate fields
on the form. When the command button was in place, the
drop down list did not return the appropriate information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box,
strContactEmail, is
bound should be a Text type field - not a Hyperlink type
field.

Here is how to get the code behind the command button:

In your form's design view, right-click on your command
button, then select
Properties from the pop-up menu. In the properties sheet
for that command
button, find the Click event and click anywhere on that
line. You will see
a downward pointing arrow at the right edge of the
line. Click it and
select Event Procedure. Then, look for the small button
to the right of the
downward pointing arrow which contains an ellipsis (three
dots ...). Click
this button to open the code window for the Click event.

When the code window is first opened, it will look like
this:

Private Sub cmdSendEmail_Click(Cancel As Integer)

End Sub

You will want to insert the following lines after
the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the Save
button. Then,
from the menu, click Debug and select Compile. Close the
code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
I have been searching newgroups for an answer to what
should be a simple question, but is not if the variety
of
replies to the question is any indication. I have a
form
that displays a record about a customer. I would like
to
add a command button to send a blank e-mail to that
customer. The control button is named "cmdSendEmail".
The text box on the form containing the e-mail address
is
named "strContactEmail". I can send an entirely blank
e-
mail, and I can e-mail a database object, but I cannot
find a way to send a blank e-mail to that particular
customer.
A caveat: Instructions such as "Put this code behind
the
command button" or anything else that assumes I know how
to add code will be a waste of your valuable time, as I
will not know what you mean. I need something that
says "Right click the command button to view its
property
sheet. Click "On Click", then click the down arrow to
see "Event Procedure", then click the three dots to
see...", etc.
A further question: The Event Procedure seems to be
heading me in the right direction, so I will ask more
about it. There is an Expression Builder, a Code
Builder,
and a Macro Builder. Which do I need, and when? Most
instructions on this matter make some reference to
building an action, which does not seem to be described
as
such in Help documentation.
I know this is a lot to ask. If it is too much for this
forum, please point me to a reference web site or to a
reference book. Thanks in advance for any assistance.


.


.
 
To the first question, yes. The form displays name,
address, phone #, etc. for the customer. It can also be
used to add or modify information about the customer. A
query is the record source for the form. The e-mail
address is contained in a text box, which is a control as
I understand the term.
To the second question, again you are correct. That
indeed is the code. When I click the button my default e-
mail program (Outlook) opens smoothly, but the To: line
(and everything else) is blank.
I appreciate all of your help, and I look forward to
solving the problem, but that will be after Christmas (on
Dec. 29) when I return to my desk.
I appreciate your generosity with your time, and would
like to extend my wish that you have a peaceful and happy
holiday season. Thanks again.
-----Original Message-----
OK. Let's go back to your original post, in which you said: "I have a form
that displays a record about a customer. I would like to
add a command button to send a blank e-mail to that customer."

I interpreted this to mean: Your form contains a control containing an
email address for that customer. You want some code that will open your
default email program, filling the To: portion of the email window with the
customer's email address. Was that correct? If not, please provide more
detail.

Skip to the current result:

You have the following code behind a command button on your form:

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink Address:=strEmail

but, when you click that button, your default email program opens with no
email address in the To: portion of the email window. Is that correct?





--
Cheryl Fischer
Law/Sys Associates
Houston, TX

This is the code in its entirety:

Private Sub cmdEmailToContact_Click()

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink ADDRESS:=strEmail

End Sub

The name of the field is now ContactEmail (I started with
it as Contact Email, but the space seemed to create
problems. The error message "Expected: End of statement"
or something like that went away when I enclosed Contact
Email in square brackets (which I thought was the system
for field names), but it made no difference. Nor does it
make a difference if I enclose ContactEmail in square
brackets. The command button opens a blank e-mail.
-----Original Message-----
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just ().

My apologies - just leave the procedure header as it
is -
do not add
anything

The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String" are in blue; the
variable name is in black.

The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the Bound Control Name the
same as the underlying Field/Query Name, most
developers
find it helpful to
do so. Opinion: Many (possibly most?) developers do not "pre-pend" field
names with type qualifiers such as "str" or "int" but reserve that
convention for variable naming. Later on (if you have not looked at the
database for a while) or in applications with lots of code, it is much
easier to differentiate variables from fields this way. However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank when
it opened (nothing in the To field). Outlook 2000 is the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration
does
not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the name
of a user-defined function, or [Event Procedure]. *There
may have been an error evaluating the function,
event,
or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named strContactEmail,
and is a text field (50 characters). The form, then, has
strContactEmail (from the query that is the record source
for the form) as the control source. At first I gave the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update,
which
is
a drop down list of vendors. Clicking the appropiate name
places all vendor information into the appropriate fields
on the form. When the command button was in place, the
drop down list did not return the appropriate information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box,
strContactEmail, is
bound should be a Text type field - not a Hyperlink type
field.

Here is how to get the code behind the command button:

In your form's design view, right-click on your command
button, then select
Properties from the pop-up menu. In the properties sheet
for that command
button, find the Click event and click anywhere on that
line. You will see
a downward pointing arrow at the right edge of the
line. Click it and
select Event Procedure. Then, look for the small button
to the right of the
downward pointing arrow which contains an ellipsis (three
dots ...). Click
this button to open the code window for the Click event.

When the code window is first opened, it will look like
this:

Private Sub cmdSendEmail_Click(Cancel As Integer)

End Sub

You will want to insert the following lines after
the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the Save
button. Then,
from the menu, click Debug and select Compile.
Close
the
code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
I have been searching newgroups for an answer to what
should be a simple question, but is not if the variety
of
replies to the question is any indication. I have a
form
that displays a record about a customer. I would like
to
add a command button to send a blank e-mail to that
customer. The control button is named "cmdSendEmail".
The text box on the form containing the e-mail address
is
named "strContactEmail". I can send an entirely blank
e-
mail, and I can e-mail a database object, but I cannot
find a way to send a blank e-mail to that particular
customer.
A caveat: Instructions such as "Put this code behind
the
command button" or anything else that assumes I
know
how
to add code will be a waste of your valuable time, as I
will not know what you mean. I need something that
says "Right click the command button to view its
property
sheet. Click "On Click", then click the down
arrow
to
see "Event Procedure", then click the three dots to
see...", etc.
A further question: The Event Procedure seems to be
heading me in the right direction, so I will ask more
about it. There is an Expression Builder, a Code
Builder,
and a Macro Builder. Which do I need, and when? Most
instructions on this matter make some reference to
building an action, which does not seem to be described
as
such in Help documentation.
I know this is a lot to ask. If it is too much
for
this
forum, please point me to a reference web site or
to
a
reference book. Thanks in advance for any assistance.


.



.


.
 
Based on your last post, it appears that the value of the control on your
form which contains the email address is not being passed to the code we are
using.

Again, getting very elemental, let's check out the text box control: Open
the form in design view and right click on the control containing the email
address. Select 'Properties' from the popup menu. We want to find the
exact name of the control, so click the tab labeled "All" or the tab labeled
"Other". The first property in the list is the Name property. We want to
use the value of this Name property in the code which passes the email
address to the code. Did we?

I'll keep this thread marked to display at the top of the group, so when you
get back from holiday and pick up on this again, I'll see your post readily.

Thank you for your kind holiday wishes. And, best wishes to you and yours
for a joyous season.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Bruce said:
To the first question, yes. The form displays name,
address, phone #, etc. for the customer. It can also be
used to add or modify information about the customer. A
query is the record source for the form. The e-mail
address is contained in a text box, which is a control as
I understand the term.
To the second question, again you are correct. That
indeed is the code. When I click the button my default e-
mail program (Outlook) opens smoothly, but the To: line
(and everything else) is blank.
I appreciate all of your help, and I look forward to
solving the problem, but that will be after Christmas (on
Dec. 29) when I return to my desk.
I appreciate your generosity with your time, and would
like to extend my wish that you have a peaceful and happy
holiday season. Thanks again.
-----Original Message-----
OK. Let's go back to your original post, in which you said: "I have a form
that displays a record about a customer. I would like to
add a command button to send a blank e-mail to that customer."

I interpreted this to mean: Your form contains a control containing an
email address for that customer. You want some code that will open your
default email program, filling the To: portion of the email window with the
customer's email address. Was that correct? If not, please provide more
detail.

Skip to the current result:

You have the following code behind a command button on your form:

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink Address:=strEmail

but, when you click that button, your default email program opens with no
email address in the To: portion of the email window. Is that correct?





--
Cheryl Fischer
Law/Sys Associates
Houston, TX

This is the code in its entirety:

Private Sub cmdEmailToContact_Click()

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink ADDRESS:=strEmail

End Sub

The name of the field is now ContactEmail (I started with
it as Contact Email, but the space seemed to create
problems. The error message "Expected: End of statement"
or something like that went away when I enclosed Contact
Email in square brackets (which I thought was the system
for field names), but it made no difference. Nor does it
make a difference if I enclose ContactEmail in square
brackets. The command button opens a blank e-mail.
-----Original Message-----
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just ().

My apologies - just leave the procedure header as it is -
do not add
anything

The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String"
are in blue; the
variable name is in black.

The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named
strContactEmail,
and is a text field (50 characters). The form, then,
has
strContactEmail (from the query that is the record
source
for the form) as the control source. At first I gave
the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the
Bound Control Name the
same as the underlying Field/Query Name, most developers
find it helpful to
do so. Opinion: Many (possibly most?) developers do
not "pre-pend" field
names with type qualifiers such as "str" or "int" but
reserve that
convention for variable naming. Later on (if you have
not looked at the
database for a while) or in applications with lots of
code, it is much
easier to differentiate variables from fields this way.
However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the
code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
Thanks for the reply, but I have to tell you it did not
work. When I started the event procedure it was as you
described, but instead of (Cancel As Integer) there was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank
when
it opened (nothing in the To field). Outlook 2000 is
the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration does
not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the
name
of a user-defined function, or [Event Procedure].
*There
may have been an error evaluating the function, event,
or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named
strContactEmail,
and is a text field (50 characters). The form, then,
has
strContactEmail (from the query that is the record
source
for the form) as the control source. At first I gave
the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as
described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update, which
is
a drop down list of vendors. Clicking the appropiate
name
places all vendor information into the appropriate
fields
on the form. When the command button was in place, the
drop down list did not return the appropriate
information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to
shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box,
strContactEmail, is
bound should be a Text type field - not a Hyperlink
type
field.

Here is how to get the code behind the command button:

In your form's design view, right-click on your command
button, then select
Properties from the pop-up menu. In the properties
sheet
for that command
button, find the Click event and click anywhere on that
line. You will see
a downward pointing arrow at the right edge of the
line. Click it and
select Event Procedure. Then, look for the small
button
to the right of the
downward pointing arrow which contains an ellipsis
(three
dots ...). Click
this button to open the code window for the Click
event.

When the code window is first opened, it will look like
this:

Private Sub cmdSendEmail_Click(Cancel As
Integer)

End Sub

You will want to insert the following lines after
the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the
Save
button. Then,
from the menu, click Debug and select Compile. Close
the
code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
I have been searching newgroups for an answer to what
should be a simple question, but is not if the
variety
of
replies to the question is any indication. I have a
form
that displays a record about a customer. I would
like
to
add a command button to send a blank e-mail to that
customer. The control button is
named "cmdSendEmail".
The text box on the form containing the e-mail
address
is
named "strContactEmail". I can send an entirely
blank
e-
mail, and I can e-mail a database object, but I
cannot
find a way to send a blank e-mail to that particular
customer.
A caveat: Instructions such as "Put this code behind
the
command button" or anything else that assumes I know
how
to add code will be a waste of your valuable time,
as I
will not know what you mean. I need something that
says "Right click the command button to view its
property
sheet. Click "On Click", then click the down arrow
to
see "Event Procedure", then click the three dots to
see...", etc.
A further question: The Event Procedure seems to be
heading me in the right direction, so I will ask more
about it. There is an Expression Builder, a Code
Builder,
and a Macro Builder. Which do I need, and when?
Most
instructions on this matter make some reference to
building an action, which does not seem to be
described
as
such in Help documentation.
I know this is a lot to ask. If it is too much for
this
forum, please point me to a reference web site or to
a
reference book. Thanks in advance for any
assistance.


.



.


.
 
It works! When I tested it, the form defaults to the
first record (in alphabetical order) in the underlying
query when I switch from design view to form view. As it
happens, that record contained an e-mail address, so I
tested the button from there (without selecting a record),
and it did not work. However, when I selected the record
(using a drop-down list at the top of the form), the
button worked as expected. A silly mistake on my part.
Thank you again for all of your patient assistance.
-----Original Message-----
Based on your last post, it appears that the value of the control on your
form which contains the email address is not being passed to the code we are
using.

Again, getting very elemental, let's check out the text box control: Open
the form in design view and right click on the control containing the email
address. Select 'Properties' from the popup menu. We want to find the
exact name of the control, so click the tab labeled "All" or the tab labeled
"Other". The first property in the list is the Name property. We want to
use the value of this Name property in the code which passes the email
address to the code. Did we?

I'll keep this thread marked to display at the top of the group, so when you
get back from holiday and pick up on this again, I'll see your post readily.

Thank you for your kind holiday wishes. And, best wishes to you and yours
for a joyous season.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

To the first question, yes. The form displays name,
address, phone #, etc. for the customer. It can also be
used to add or modify information about the customer. A
query is the record source for the form. The e-mail
address is contained in a text box, which is a control as
I understand the term.
To the second question, again you are correct. That
indeed is the code. When I click the button my default e-
mail program (Outlook) opens smoothly, but the To: line
(and everything else) is blank.
I appreciate all of your help, and I look forward to
solving the problem, but that will be after Christmas (on
Dec. 29) when I return to my desk.
I appreciate your generosity with your time, and would
like to extend my wish that you have a peaceful and happy
holiday season. Thanks again.
-----Original Message-----
OK. Let's go back to your original post, in which you said: "I have a form
that displays a record about a customer. I would like to
add a command button to send a blank e-mail to that customer."

I interpreted this to mean: Your form contains a
control
containing an
email address for that customer. You want some code
that
will open your
default email program, filling the To: portion of the email window with the
customer's email address. Was that correct? If not, please provide more
detail.

Skip to the current result:

You have the following code behind a command button on your form:

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink Address:=strEmail

but, when you click that button, your default email program opens with no
email address in the To: portion of the email window.
Is
that correct?
--
Cheryl Fischer
Law/Sys Associates
Houston, TX

This is the code in its entirety:

Private Sub cmdEmailToContact_Click()

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink ADDRESS:=strEmail

End Sub

The name of the field is now ContactEmail (I started with
it as Contact Email, but the space seemed to create
problems. The error message "Expected: End of statement"
or something like that went away when I enclosed Contact
Email in square brackets (which I thought was the system
for field names), but it made no difference. Nor
does
it
make a difference if I enclose ContactEmail in square
brackets. The command button opens a blank e-mail.
-----Original Message-----
Thanks for the reply, but I have to tell you it
did
not
work. When I started the event procedure it was
as
you
described, but instead of (Cancel As Integer)
there
was
just ().

My apologies - just leave the procedure header as it is -
do not add
anything

The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String"
are in blue; the
variable name is in black.

The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named
strContactEmail,
and is a text field (50 characters). The form, then,
has
strContactEmail (from the query that is the record
source
for the form) as the control source. At first I gave
the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the
Bound Control Name the
same as the underlying Field/Query Name, most developers
find it helpful to
do so. Opinion: Many (possibly most?) developers do
not "pre-pend" field
names with type qualifiers such as "str" or "int" but
reserve that
convention for variable naming. Later on (if you have
not looked at the
database for a while) or in applications with lots of
code, it is much
easier to differentiate variables from fields this way.
However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the
code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
Thanks for the reply, but I have to tell you it
did
not
work. When I started the event procedure it was
as
you
described, but instead of (Cancel As Integer)
there
was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and Compile
produced no error messages, but the e-mail was blank
when
it opened (nothing in the To field). Outlook 2000 is
the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was in a
different color, and when I tried to Debug and Compile I
received the error message "Procedure declaration does
not
match description of event or procedure having the same
name." When I tried clicking the button (in form view),
the following was appended to the error message: "*The
expression may not result in the name of a macro, the
name
of a user-defined function, or [Event Procedure].
*There
may have been an error evaluating the function, event,
or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a query,
which in turn draws information from a main table. The
relevant field in the Main Table is named
strContactEmail,
and is a text field (50 characters). The form, then,
has
strContactEmail (from the query that is the record
source
for the form) as the control source. At first I gave
the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as
described
above (I did change the name in the code). (Question:
What is a standard naming convention for the text box on
the form?).
The only other event on the form is After Update, which
is
a drop down list of vendors. Clicking the appropiate
name
places all vendor information into the appropriate
fields
on the form. When the command button was in
place,
the
drop down list did not return the appropriate
information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to
shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box,
strContactEmail, is
bound should be a Text type field - not a Hyperlink
type
field.

Here is how to get the code behind the command button:

In your form's design view, right-click on your command
button, then select
Properties from the pop-up menu. In the properties
sheet
for that command
button, find the Click event and click anywhere
on
that
line. You will see
a downward pointing arrow at the right edge of the
line. Click it and
select Event Procedure. Then, look for the small
button
to the right of the
downward pointing arrow which contains an ellipsis
(three
dots ...). Click
this button to open the code window for the Click
event.

When the code window is first opened, it will
look
like
this:

Private Sub cmdSendEmail_Click(Cancel As
Integer)

End Sub

You will want to insert the following lines after
the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the
Save
button. Then,
from the menu, click Debug and select Compile. Close
the
code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX

"Bruce" <[email protected]>
wrote
in
message
I have been searching newgroups for an answer
to
what
should be a simple question, but is not if the
variety
of
replies to the question is any indication. I have a
form
that displays a record about a customer. I would
like
to
add a command button to send a blank e-mail to that
customer. The control button is
named "cmdSendEmail".
The text box on the form containing the e-mail
address
is
named "strContactEmail". I can send an entirely
blank
e-
mail, and I can e-mail a database object, but I
cannot
find a way to send a blank e-mail to that particular
customer.
A caveat: Instructions such as "Put this code behind
the
command button" or anything else that assumes I know
how
to add code will be a waste of your valuable time,
as I
will not know what you mean. I need something that
says "Right click the command button to view its
property
sheet. Click "On Click", then click the down arrow
to
see "Event Procedure", then click the three
dots
to
see...", etc.
A further question: The Event Procedure seems
to
be
heading me in the right direction, so I will
ask
more
about it. There is an Expression Builder, a Code
Builder,
and a Macro Builder. Which do I need, and when?
Most
instructions on this matter make some reference to
building an action, which does not seem to be
described
as
such in Help documentation.
I know this is a lot to ask. If it is too much for
this
forum, please point me to a reference web site
or
to
a
reference book. Thanks in advance for any
assistance.


.



.



.


.
 
Thanks for posting back with your results!

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Bruce said:
It works! When I tested it, the form defaults to the
first record (in alphabetical order) in the underlying
query when I switch from design view to form view. As it
happens, that record contained an e-mail address, so I
tested the button from there (without selecting a record),
and it did not work. However, when I selected the record
(using a drop-down list at the top of the form), the
button worked as expected. A silly mistake on my part.
Thank you again for all of your patient assistance.
-----Original Message-----
Based on your last post, it appears that the value of the control on your
form which contains the email address is not being passed to the code we are
using.

Again, getting very elemental, let's check out the text box control: Open
the form in design view and right click on the control containing the email
address. Select 'Properties' from the popup menu. We want to find the
exact name of the control, so click the tab labeled "All" or the tab labeled
"Other". The first property in the list is the Name property. We want to
use the value of this Name property in the code which passes the email
address to the code. Did we?

I'll keep this thread marked to display at the top of the group, so when you
get back from holiday and pick up on this again, I'll see your post readily.

Thank you for your kind holiday wishes. And, best wishes to you and yours
for a joyous season.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

To the first question, yes. The form displays name,
address, phone #, etc. for the customer. It can also be
used to add or modify information about the customer. A
query is the record source for the form. The e-mail
address is contained in a text box, which is a control as
I understand the term.
To the second question, again you are correct. That
indeed is the code. When I click the button my default e-
mail program (Outlook) opens smoothly, but the To: line
(and everything else) is blank.
I appreciate all of your help, and I look forward to
solving the problem, but that will be after Christmas (on
Dec. 29) when I return to my desk.
I appreciate your generosity with your time, and would
like to extend my wish that you have a peaceful and happy
holiday season. Thanks again.
-----Original Message-----
OK. Let's go back to your original post, in which you
said: "I have a form
that displays a record about a customer. I would like to
add a command button to send a blank e-mail to that
customer."

I interpreted this to mean: Your form contains a control
containing an
email address for that customer. You want some code that
will open your
default email program, filling the To: portion of the
email window with the
customer's email address. Was that correct? If not,
please provide more
detail.

Skip to the current result:

You have the following code behind a command button on
your form:

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink Address:=strEmail

but, when you click that button, your default email
program opens with no
email address in the To: portion of the email window. Is
that correct?





--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
This is the code in its entirety:

Private Sub cmdEmailToContact_Click()

Dim strEmail As String

strEmail = "mailto:" & Me!ContactEmail
Application.FollowHyperlink ADDRESS:=strEmail

End Sub

The name of the field is now ContactEmail (I started
with
it as Contact Email, but the space seemed to create
problems. The error message "Expected: End of
statement"
or something like that went away when I enclosed Contact
Email in square brackets (which I thought was the system
for field names), but it made no difference. Nor does
it
make a difference if I enclose ContactEmail in square
brackets. The command button opens a blank e-mail.
-----Original Message-----
Thanks for the reply, but I have to tell you it did
not
work. When I started the event procedure it was as
you
described, but instead of (Cancel As Integer) there
was
just ().

My apologies - just leave the procedure header as it
is -
do not add
anything

The line Dim strEmail as String had "Dim"
and "As String" in a different color.

That is normal. In my VBA editor "Dim" and "as String"
are in blue; the
variable name is in black.

The form draws information from a query,
which in turn draws information from a main table.
The
relevant field in the Main Table is named
strContactEmail,
and is a text field (50 characters). The form, then,
has
strContactEmail (from the query that is the record
source
for the form) as the control source. At first I gave
the
text box on the form the name strContactEmail, then I
tried a different name

That is fine. While you are not required to make the
Bound Control Name the
same as the underlying Field/Query Name, most
developers
find it helpful to
do so. Opinion: Many (possibly most?) developers do
not "pre-pend" field
names with type qualifiers such as "str" or "int" but
reserve that
convention for variable naming. Later on (if you have
not looked at the
database for a while) or in applications with lots of
code, it is much
easier to differentiate variables from fields this way.
However, use
whatever consistent naming convention works for you.

If problems continue, please post back and include the
code you are using.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

message
Thanks for the reply, but I have to tell you it did
not
work. When I started the event procedure it was as
you
described, but instead of (Cancel As Integer) there
was
just (). The line Dim strEmail as String had "Dim"
and "As String" in a different color. Debug and
Compile
produced no error messages, but the e-mail was blank
when
it opened (nothing in the To field). Outlook 2000 is
the
e-mail program, by the way. When I added Cancel As
Integer" between the parentheses, "As Integer" was
in a
different color, and when I tried to Debug and
Compile I
received the error message "Procedure declaration
does
not
match description of event or procedure having the
same
name." When I tried clicking the button (in form
view),
the following was appended to the error
message: "*The
expression may not result in the name of a macro, the
name
of a user-defined function, or [Event Procedure].
*There
may have been an error evaluating the function,
event,
or
macro." (This was with Cancel as Integer added).
Here is the information that could be relevant, as I
understand it: The form draws information from a
query,
which in turn draws information from a main table.
The
relevant field in the Main Table is named
strContactEmail,
and is a text field (50 characters). The form, then,
has
strContactEmail (from the query that is the record
source
for the form) as the control source. At first I gave
the
text box on the form the name strContactEmail, then I
tried a different name. Result in both cases as
described
above (I did change the name in the code).
(Question:
What is a standard naming convention for the text
box on
the form?).
The only other event on the form is After Update,
which
is
a drop down list of vendors. Clicking the appropiate
name
places all vendor information into the appropriate
fields
on the form. When the command button was in place,
the
drop down list did not return the appropriate
information;
rather, the same error message as described above
appeared. With the offending code deleted, the form
worked properly, as it did before I tried to add the
command button.
Thanks in advance for any light you might be able to
shed
on this.
-----Original Message-----

Here is the code to put behind your command button:

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

NOTE: The table field to which your text box,
strContactEmail, is
bound should be a Text type field - not a Hyperlink
type
field.

Here is how to get the code behind the command
button:

In your form's design view, right-click on your
command
button, then select
Properties from the pop-up menu. In the properties
sheet
for that command
button, find the Click event and click anywhere on
that
line. You will see
a downward pointing arrow at the right edge of the
line. Click it and
select Event Procedure. Then, look for the small
button
to the right of the
downward pointing arrow which contains an ellipsis
(three
dots ...). Click
this button to open the code window for the Click
event.

When the code window is first opened, it will look
like
this:

Private Sub cmdSendEmail_Click(Cancel As
Integer)

End Sub

You will want to insert the following lines after
the "Private Sub
cmdSendEmail_Click(Cancel as Integer)" line

Dim strEmail as String

strEmail = "mailto:" & Me!strContactEmail
Application.FollowHyperlink Address:=strEmail

While you still have the code window open, click the
Save
button. Then,
from the menu, click Debug and select Compile.
Close
the
code window; save
your form and return it to form view.






--
Cheryl Fischer
Law/Sys Associates
Houston, TX

in
message
I have been searching newgroups for an answer to
what
should be a simple question, but is not if the
variety
of
replies to the question is any indication. I
have a
form
that displays a record about a customer. I would
like
to
add a command button to send a blank e-mail to
that
customer. The control button is
named "cmdSendEmail".
The text box on the form containing the e-mail
address
is
named "strContactEmail". I can send an entirely
blank
e-
mail, and I can e-mail a database object, but I
cannot
find a way to send a blank e-mail to that
particular
customer.
A caveat: Instructions such as "Put this code
behind
the
command button" or anything else that assumes I
know
how
to add code will be a waste of your valuable time,
as I
will not know what you mean. I need something
that
says "Right click the command button to view its
property
sheet. Click "On Click", then click the down
arrow
to
see "Event Procedure", then click the three dots
to
see...", etc.
A further question: The Event Procedure seems to
be
heading me in the right direction, so I will ask
more
about it. There is an Expression Builder, a Code
Builder,
and a Macro Builder. Which do I need, and when?
Most
instructions on this matter make some reference to
building an action, which does not seem to be
described
as
such in Help documentation.
I know this is a lot to ask. If it is too much
for
this
forum, please point me to a reference web site or
to
a
reference book. Thanks in advance for any
assistance.


.



.



.


.
 
Back
Top