J Warren said:
Hello,
I currently have an access form that reads a table of email address. I
have set the email field Properties to Hyperlink. When the field is
shown it shows the selected email address as a hyperlink but is does
nothing when clicked on. Is there a way to set the field to open a new
email from my default email program?
You have to make sure it's a "mailto:" hyperlink. Unfortunately, Access
seems almost perversely to assume that anything you type in a hyperlink
field is an http: address. If you edit the hyperlink using Insert ->
Hyperlink (and choose to insert an e-mail address), or if you type
"mailto:" before the address, it will be interpreted correctly, and then
it will behave the way you want when you click on it.
If you want to avoid having to type "mailto:" on your form, you can
correct Access's misapprehension with code in the control's AfterUpdate
event, along these lines:
'---- start of example code ----
Private Sub HyperlinkField_AfterUpdate()
Dim strAddress As String
If Len(Me.HyperlinkField & vbNullString) > 0 Then
strAddress = HyperlinkPart(Me.HyperlinkField, acAddress)
If Left(strAddress, 7) = "http://" Then
Me.HyperlinkField = _
HyperlinkPart(Me.HyperlinkField, acDisplayText) & _
"#mailto:" & Mid(strAddress, 8) & "#" & _
HyperlinkPart(Me.HyperlinkField, acSubAddress)
End If
End If
End Sub
'---- end of example code ----
My personal preference is to forgo hyperlink fields entirely, and just
use text fields. Then when I want to "follow" the link, I can use
DoCmd.SendObject or Application.FollowHyperlink:
'---- start of example code #2 ----
Private Sub EmailAddress_DblClick()
Application.FollowHyperlink "mailto:" & Me.EmailAddress
End Sub
'---- end of example code #2 ----