What's up with this???

F

Freehal04

So I tried to fix my hyperlink field for my email so it would add the
'mailto:' in front of what a user types in. Here's what I have.

Private Sub Email_AfterUpdate()
' If you just type in an email name: [email protected]
' Access changes it to: [email protected]#http://[email protected]# !!
' This code tries to fix it
Dim intI As Integer
' Don't do anything if email is empty
If IsNull(Me.PMemailAddress) Then Exit Sub
' Fix up http:// if it's there
Me.PMemailAddress = Replace(Me.PMemailAddress, "http://", "mailto:")
' Now look for the first"#" that delimits the hyperlink display name
intI = InStr(Me.PMemailAddress, "#")
' And put the person name there instead if found
If intI > 0 Then
Me.PMemailAddress = (Me.PMemailAddress + " ") & Me.LastName & _
Mid(Me.PMemailAddress, intI)
End If
End Sub

When I try to type something in I get a compile error "Method or data member
not found. and it highlights the line before the End if,
Mid(Me.PMemailAddress,intI)

I don't get it. What's wrong.
 
A

Arvin Meyer [MVP]

Try this:

Private Sub cmdEmail_Click()
Dim strMail As String
strMail = "#MailTo:" & Me.txtEMail & "#"
Application.FollowHyperlink HyperlinkPart(strMail, acAddress)
End Sub

The above uses a plain text field and textbox (txtEmail) to mail from an
email address in the database. Three advantages:

1. Your problem is solved
2. Larger file size of hyperlinks is eclipsed
3. Less chance of corruption
 
F

Freehal04

Okay, thanks. So I should change my email field from a hyperlink to a plain
text field?
 
W

Wayne-I-M

You have PMemailAddress and Arvin has txtEMail

You need to alter Arvin's code to what you use on your on form so that it
works for you.

: - )
 
A

Arvin Meyer [MVP]

It doesn't change anything, it emails correctly formed email addresses when
you click on the button named cmdEmail. If you have http://whatever in the
hyperlink, you'll need to delete anything that's not part of the email
address after you've changed the table's field from hyperlink to text.
 
Top