Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

E-mail hyperlink

1 view
Skip to first unread message

Adam Hicks

unread,
Jun 16, 2003, 8:55:30 AM6/16/03
to
Hello. I have a field e-mail address how can I make it
when they type a e-mail address in that field it shows up
as a hyperlink and then when they click on it it opens up
outlook and gets ready to send a e-mail with that
address.

Thanks Adam

Dirk Goldgar

unread,
Jun 16, 2003, 12:16:12 PM6/16/03
to
"Adam Hicks" <ahi...@conewago.com> wrote in message
news:085d01c33406$912d5060$a101...@phx.gbl

There are a couple of options available to you.

Approach 1
------------
You can set the field as a hyperlink field, rather than a plain text
field. Then you'll automatically get the "pointing hand" cursor when
your mouse is over the field, and clicking it will automatically follow
the hyperlink. Unfortunately, Access generally assumes that anything
you enter in a hyperlink field is a web address, and prefixes the
address part of the hyperlink with "http://" unless you type in the
"mailto:" prefix. The way around this is to use code in the AfterUpdate
event of any control bound to this field, to replace the "http://"
prefix with "mailto:". Here's an example of such code:

'----- start of example #1 code -----
Private Sub EmailAddress_AfterUpdate()

If Not IsNull(Me.EmailAddress) Then
Me.EmailAddress = _
Replace(Me.EmailAddress, _
"http://", "mailto:", , , vbTextCompare)
End If

End Sub
'----- end of example #1 code -----

Approach 2
------------
Instead of a hyperlink field, use a plain text field for the e-mail
address. Use code in a suitable event -- the DblClick event of the
[EmailAddress] text box, or the Click of a command button -- to call the
Application.FollowHyperlink method to open the e-mail. In this case,
you'd add the "mailto:" prefix yourself. Here's example code:

'----- start of example #2 code -----
Private Sub EmailAddress_DblClick(Cancel As Integer)

Dim strEmail As String

If Not IsNull(Me.EmailAddress) Then
strEmail = Me.EmailAddress
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If

End Sub
'----- end of example #2 code -----

If you really want the control to behave like a hyperlink field, you
could use the Click event of the text box, but I prefer not to do that,
as then I can't "click into" the field to edit it.

With this approach, the "hand" cursor won't automatically appear when
the mouse moves over the [EmailAddress] text box. You can make it do
that, if you really want to, by controlling the cursor yourself using
code from this link:

http://www.mvps.org/access/api/api0044.htm

in the MouseMove event of the control.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


0 new messages