How do I format a field in a table to default to email (mailto:)?

S

slreilly

I'm putting a form together to log email addresses. It keeps defaulting to
the http format, not the mailto format. How do you set this automatically in
the table that stores them? thanks.
 
M

Mikal via AccessMonster.com

This isn't my solution. I think it's Albert Kallal's, but I may be mistaken.
It's been a long time since I found it in this forum. Basically, you store
your addresses in a text field, not a hyperlink field. In the form that
displays your data, put this code in the onclick event of a button or the
control linked to the field:

Private Sub SecretaryEmail_Click()
Dim strEmail As String
If Not IsNull(Me.SecretaryEmail) Then
strEmail = Me.SecretaryEmail
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If
End Sub

SecretaryEmail in the above example is the name of the field in my table.
You will need to change it to the name of your field.

If you use blue underlined text in the control, it will look just like a
hyperlink and act like one, too.

Hope this helps.

Mike
 
M

Mikal via AccessMonster.com

Come to think of it, SecretaryEmail is also the name of the text box on the
form that displays the address and probably you need to change it to the name
of your textbox, not of the field in your table. I really need to pay more
attention to using a consistent naming convention.

Mike
 
S

slreilly

Thanks. Worked like a charm.
Seana

Mikal via AccessMonster.com said:
This isn't my solution. I think it's Albert Kallal's, but I may be mistaken.
It's been a long time since I found it in this forum. Basically, you store
your addresses in a text field, not a hyperlink field. In the form that
displays your data, put this code in the onclick event of a button or the
control linked to the field:

Private Sub SecretaryEmail_Click()
Dim strEmail As String
If Not IsNull(Me.SecretaryEmail) Then
strEmail = Me.SecretaryEmail
If Left(strEmail, 7) <> "mailto:" Then
strEmail = "mailto: " & strEmail
End If
Application.FollowHyperlink strEmail
End If
End Sub

SecretaryEmail in the above example is the name of the field in my table.
You will need to change it to the name of your field.

If you use blue underlined text in the control, it will look just like a
hyperlink and act like one, too.

Hope this helps.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top