E-Mail hyperlink fields

  • Thread starter Thread starter john431
  • Start date Start date
J

john431

I have an active database with an e-mail address field.
How can I easily convert it to a hyperlink field that
will send an e-mail to a given address when selected?

I would prefer not to have to type in all the e-mail
addresses again using the Edit Hyperlink dialog box so
that the "mailto:" prefix is added to the e-mail address.
 
It is a "PITA" to have to change a hyperlink from "http://" to mailto://.
However, you can achieve the objective of using your email address in a
TextBox to send an email by using Application.FollowHyperlink. Here is how:

Presuming that your form has a text box control named: EMail: You can use
the control's properties to make the ForeColor blue and Underscored (so that
it looks "special and kind of like a hyperlink"). Then insert the
following code behind the Double Click event of that text box.

Dim strEmail as String

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

Substitute your actual field name for EMail in the above code.

In the event that this is the first time that you will have to code an
event, here is how to do it:

In your form's design view, right-click on the text box containing the email
address, then select Properties from the pop-up menu. In the properties
sheet for that text box, find the DblClick 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 Dbl Click event.

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

Private Sub Email_DblClick(Cancel As Integer)

End Sub

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

Dim strEmail as String

strEmail = "mailto:" & Me.[EMail]
Application.FollowHyperlink Address:=strEmail

Save and close the code window; save your form and return it to form view.
Double click on your text box email value and you should be fine.



hth,
 
Back
Top