Hyper link Mailto: also tries to go to webpage

jamierbooth

Registered User.
Local time
Today, 11:44
Joined
Oct 23, 2013
Messages
36
Hi guys. This may be simple, but my guide book I have doesn't explain and my searches on the subject all seem to be people with rather complicated issues.

MS Access 2000 - Quite simply, on a form I have an Email field and I have the "Is Hyperlink" property set to yes. In the On-Click event of this email field I use this single line of code below to open a new outlook (2007) email with the address already entered. Staff will be entering the email address themselves as part of the clients contact details Form.

Code:
FollowHyperlink "mailto: " & [Email]

This is all fine, however access also tacks #http://bob.jones@email.com# onto the end of the email address and tries to also open a web page which obviously fails.

Is there something somewhere I can tweak that tells access to always only treat the text in this field as an email address, and when clicked open an email?

Cheers. Jamie.
 
Set the Is Hyperlink to No, under format, change the formatting to "look like a hyperlink". Then On Click code it to do the email code..
Code:
DoCmd.SendObject acSendNoObject,To:=Me.Email
 
Thanks. That works fine, although I get an error message 2501 (Sendobject action cancelled) if I close the email without actually sending it.

Have tried to suppress this with an error handler in the On-Click code to no avail...
Code:
ErrHandler:
    If DataErr = 2501 Then
        Resume ExitHandler
    Else
        MsgBox Err.Description
        Resume ExitHandler
    End If

Any ideas?

Jamie.
 
This should work !
Code:
Private Sub yourButton_Click()
On Error GoTo errHandler
    DoCmd.SendObject acSendNoObject, To:=Me.emailAddress
exitErr:
    Exit Sub
errHandler:
    If Err.Number <> 2501 Then MsgBox Err.Number & " - " & Err.Description, vbInformation, "Some error occured !"
    Resume exitErr
End Sub
 
Lovely cheers. I took off the msgbox bit, because I didn't any message coming up, but altering that error code slightly to match yours has done the trick. Thanks.
Code:
Private Sub txtEmail_Click()
    On Error GoTo ErrHandler
    
DoCmd.SendObject acSendNoObject, To:=Me.Email
 
ExitHandler:
    Exit Sub
 
ErrHandler:
    If Err.Number <> 2501 Then
        Resume ExitHandler
    End If

End Sub
 
Based on your code, you are not handling any errors.. At all. So you might as well do this..
Code:
Private Sub txtEmail_Click()
On Error Resume Next
    DoCmd.SendObject acSendNoObject, To:=Me.Email
End Sub
Would save memory and also less confusing to anyone looking at the code. ;)
 

Users who are viewing this thread

Back
Top Bottom