Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Clickable Email Address Field

2 views
Skip to first unread message

Allen Browne

unread,
Nov 26, 2005, 1:58:54 AM11/26/05
to
Is this field a Text field or a Hyperlink field?

If Hyperlink, Access will insert an http:// in front of the email address,
and it won't work correctly. It is possible to use HyperlinkPart() to parse
out the display name and address from the link and create it with a mailto:
prefix instead, but this is unnecessarily messy.

A better solution is probably just to store the value in a Text field. Then
use the SendObject action in the Click (or DblClick) event of the text box
on your form. If your field is named Email, this would be line to enter in
your event procedure:
DoCmd.SendObject acSendNoObject, To:= Me.Email

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Texastoneman" <Texast...@discussions.microsoft.com> wrote in message
news:5E06D33A-64C1-49CA...@microsoft.com...
>I have a field that contains email addresses for clients and I want it to
>be
> a clickable link. How do I make it so I can click on it and it will open
> my
> email client and starty a message to that person? I do know how to do it
> by
> editing the hyperlink individually in the table view, but not setting it
> up
> for all my data records so that when I enter a new email address, it is
> clickable.
>
> I have been working on this for a while. Please help.


Texastoneman

unread,
Nov 28, 2005, 1:11:05 PM11/28/05
to
Allen,

Thanks for the tips. One problem. First of all, I am familiar with Access,
but not familiar with the Visual Basic portion of macros so you will have to
excuse me. When I entered the code you posted in my TEXT field (like you
mentioned), it did in fact start an email to the individual, but if I closed
the started email without sending it, it gave me an error. Specifically, it
says the following:

Run-time error '2501'
The SendObject action was cancelled

What do I do to prevent this error from happening?

Second thought: I also have a standard signature and etc that I use with
Microsoft Outlook, will this not pull up either on the started email from the
double click?

Thank you for your tips and I just want to make sure I get it right if
possible.

Justin

Allen Browne

unread,
Nov 28, 2005, 9:09:19 PM11/28/05
to
Add error handling to the routine, and ignore error 2501.

Something like this:

Private Sub Email_DblClick(Cancel As Integer)
On Error Goto Err_Handler

DoCmd.SendObject acSendNoObject, To:= Me.Email

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & " - " & Err.Description
End If
Resume Exit_Handler
End Sub


For more info in error handling, see:
http://allenbrowne.com/ser-23a.html

The signature issue depends on your email program. You can't modify that
from SendObject.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Texastoneman" <Texast...@discussions.microsoft.com> wrote in message

news:C2AAB8F5-8A7D-4EF4...@microsoft.com...

jmuirman

unread,
Jan 1, 2006, 11:29:02 AM1/1/06
to
Tried this and couldn't make it work - my field is called [email address] and
I pasted the do command in as you said but I'm not familiar language.

Thanks,

John

Allen Browne

unread,
Jan 1, 2006, 8:47:52 PM1/1/06
to
Firstly, open your table in design view, and make sure your [email address]
field is a Text type, not a Hyperlink type. Save. Close.

Then open your form in design view.
Right-click the text box, and choose Properties.
Set the DblClick property to:
[Event Procedure]
Click the Build button (...) beside that.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, paste:
DoCmd.SendObject acSendNoObject, To:= Me.[email address]
Save the changes.
Open the form.
Double-click the [email address] control.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"jmuirman" <jmui...@discussions.microsoft.com> wrote in message
news:BE51A74C-A9A9-4CD9...@microsoft.com...


> Tried this and couldn't make it work - my field is called [email address]
> and
> I pasted the do command in as you said but I'm not familiar language.
>
> Thanks,
>
> John
>
> "Allen Browne" wrote:
>
>> Is this field a Text field or a Hyperlink field?
>>
>> If Hyperlink, Access will insert an http:// in front of the email
>> address,
>> and it won't work correctly. It is possible to use HyperlinkPart() to
>> parse
>> out the display name and address from the link and create it with a
>> mailto:
>> prefix instead, but this is unnecessarily messy.
>>
>> A better solution is probably just to store the value in a Text field.
>> Then
>> use the SendObject action in the Click (or DblClick) event of the text
>> box
>> on your form. If your field is named Email, this would be line to enter
>> in
>> your event procedure:
>> DoCmd.SendObject acSendNoObject, To:= Me.Email
>>
>>

jmuirman

unread,
Jan 1, 2006, 11:43:01 PM1/1/06
to
Thanks for your help - I got a 2501 run time error but found your answer in
another post - again - Thanks,

BruceM

unread,
Jan 3, 2006, 7:06:06 AM1/3/06
to
You probably got the error when you canceled the e-mail without sending it.
You can trap that error.

"jmuirman" <jmui...@discussions.microsoft.com> wrote in message

news:A9535B11-4979-46A4...@microsoft.com...

Nancy

unread,
Feb 8, 2006, 3:18:27 PM2/8/06
to
Some of my email addresses have HTTP in front and some don't. All were
entered the same way (without http). Changed properties to "IS Hyperlink
...Yes" and that still doesn't fix. Any ideas?

Allen Browne

unread,
Feb 8, 2006, 7:51:09 PM2/8/06
to
Hi Nancy.

Use a Text type field, not a Hyperlink field.

Once you have opened the table in design view, and changed the field type,
if the addresses still have the http:// in front of them, you could:
- Create a query using this table.
- Change it to an Update query (Update on Query menu).
- In the Update row under the Email address field, enter:
Replace([Email], "http://", "mailto:")
- Run the query to make the change.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nancy" <Na...@discussions.microsoft.com> wrote in message
news:5A423F58-CCC1-401B...@microsoft.com...


> Some of my email addresses have HTTP in front and some don't. All were
> entered the same way (without http). Changed properties to "IS Hyperlink
> ...Yes" and that still doesn't fix. Any ideas?
>
> "Allen Browne" wrote:
>
>> Firstly, open your table in design view, and make sure your [email
>> address]
>> field is a Text type, not a Hyperlink type. Save. Close.
>>
>> Then open your form in design view.
>> Right-click the text box, and choose Properties.
>> Set the DblClick property to:
>> [Event Procedure]
>> Click the Build button (...) beside that.
>> Access opens the code window.
>> Between the "Private Sub..." and "End Sub" lines, paste:
>> DoCmd.SendObject acSendNoObject, To:= Me.[email address]
>> Save the changes.
>> Open the form.
>> Double-click the [email address] control.
>>

0 new messages