replace http:// with mailto:

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

when entering an e-mail address on my form, Access 2000 changes it so that it
links to a webpage. How can I replace the "http://" with "mailto:" after
update?
 
in message:
when entering an e-mail address on my form, Access 2000 changes it so that it
links to a webpage. How can I replace the "http://" with "mailto:" after
update?

Hi,

It sounds like you have the table field defined to be a Hyperlink field.
I would set the field to be a text field, not Hyperlink to avoid this problem.

Here is a past post of mine on this issue which details how to avoid
the problem you are having, as well as how to send the person an e-mail
message by double clicking on that form field.
1. Make a field in the table called EmailAddress set as Text (not hyperlink).

2. Enter the e-mail addresses like so on the data entry form:
(e-mail address removed)
They will not have to type the "mailto" part

3. Code the double-click event of that field's control on the data entry form like so:

Private Sub EmailAddress_DblClick(Cancel As Integer)
On Error GoTo ErrorPoint

Dim strEmail As String

' Stop the Web Toolbar from appearing
DoCmd.ShowToolbar "Web", acToolbarNo

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

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description, vbExclamation, _
"Unexpected Error"
Resume ExitPoint

End Sub

Double-clicking on that field will bring up Outlook (assuming that is
what you are using) with a new message and their e-mail address already filled in.
Hope that gets you going,
 
Tlaker,

Do you mean that Access is literally inserting a "http://" string in
front of the data you are entering? I have not seen this before. As
you have suggested, you will get the behaviour you seek if the mailto
protocol identifier is used in your data. I would normally use code
like this on the afterupdate event of the control...
If Me.Email Like "mailto:*" Then
' do nothing
Else
Me.Email = "mailto:" & Me.Email
End If

But this assumes the code is just working with the text you entered. If
you literally have a http identifier there, try it like this...
If Me.Email Like "mailto:*" Then
' do nothing
ElseIf Me.Email Like "http*" Then
Me.Email = Replace(Me.Email,"http://","mailto:")
Else
Me.Email = "mailto:" & Me.Email
End If
 
thanks Jeff, I'll give it a try

Jeff Conrad said:
in message:


Hi,

It sounds like you have the table field defined to be a Hyperlink field.
I would set the field to be a text field, not Hyperlink to avoid this problem.

Here is a past post of mine on this issue which details how to avoid
the problem you are having, as well as how to send the person an e-mail
message by double clicking on that form field.

1. Make a field in the table called EmailAddress set as Text (not hyperlink).

2. Enter the e-mail addresses like so on the data entry form:
(e-mail address removed)
They will not have to type the "mailto" part

3. Code the double-click event of that field's control on the data entry form like so:

Private Sub EmailAddress_DblClick(Cancel As Integer)
On Error GoTo ErrorPoint

Dim strEmail As String

' Stop the Web Toolbar from appearing
DoCmd.ShowToolbar "Web", acToolbarNo

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

ExitPoint:
Exit Sub

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description, vbExclamation, _
"Unexpected Error"
Resume ExitPoint

End Sub

Double-clicking on that field will bring up Outlook (assuming that is
what you are using) with a new message and their e-mail address already filled in.

Hope that gets you going,
 
This code to create an email by double clicking is great! Can code be added
so that not only will it fill in the email address, it will fill in the
subject line and message body based on two separate text fields that I
already have populated?
 
To update many email at once in 2003 create an update query. In design type
'<a href="mailto:'++'">'+[EMAIL]+'</a>' in Update To:. It will then
update your table.
 
Back
Top