how can i get access to open up Outlook by clicking on an email ad

S

Shazza

I am currently setting up a database and have a query on it. So far I've
done my tables and relationships and have created forms. I want the form to
be user friendly so when anyone needs to add information to it then it can be
done simply. This particular form includes contact information of
businesses. There are fields for an e-mail address and web address which I
have made hyperlink columns so when I enter data into these fields and click
on it, it tries to connect to a website. This is fine for the field
"Website" but for the e-mail address I would like it to open outlook when
clicked. I have managed to edit the hyperlink manually for every address I
have already entered which means that they are now all linked to e-mail
addresses rather than web addresses. This was time consuming and users of the
database who just want to enter information may not know how to do this. I
was wondering is it possible to edit the whole e-mail column so that when an
e-mail address in entered into it, it is automatically linked to an e-mail
address?
 
B

BruceM

If I understand correctly you want to send an e-mail by clicking on the text
box containing the e-mail address. You could have something like this as
the text box Click event:

Private Sub txtEmail_Click()

On Error GoTo ProcErr

DoCmd.SendObject , , , Nz(Me.Email,"")

ProcExit:
Exit Sub

ProcErr:
If Err.Number <> 2501 Then ' 2501: Sending e-mail was canceled
MsgBox "Error " & Err.Number & " (" & Err.Description & ") " & _
"in txtEmail_DblClick, Form_frmAddress"
End If
Resume ProcExit

End Sub

This code opens an e-mail message to the address in the Email field. The
code assumes Email is the name of the field containing the e-mail address,
and txtEmail is the name of the text box bound to that field. Use whatever
names you choose. See Help for more about SendObject. The Nz function in
the address argument avoids an error if the field is null. In that case the
e-mail message is not addressed to anybody. I added error handling to
ignore Error 2501, which appears if the user closes the e-mail instead of
sending it.

You may want to consider using the double click event, or a command button
click event, instead of the txtEmail click event. With the click event as
written the user can't click into the text box to enter the information in
the first place (although they can Tab into it). You could prevent that by
replacing this code:
DoCmd.SendObject , , , Nz(Me.Email,"")
with this:
If Not IsNull(Me.Email) Then
DoCmd.SendObject, , , Me.Email
End If

Another consideration against using the Click event is that editing will be
more difficult.
 
R

Ron2006

If you simply make both of those fields txt fields and txt boxes, it
makes entry extremely easy.

Then....

On the Web addres field add code to the dbl-click event to
application.followhyperlink me.txtfieldname

On the email address add code to the dbl-click event to:

Application.FollowHyperlink "mailto:" & Me.fieldname

Ron
 
J

jenniferd

Hi Ron!

I have a media document that was sent to me with e-mail addressess and I
can't figure out how to be able to click on the e-mail address in the excel
document and lhave it link out as and e-mail. I read your post and I was
wondering if you could help me as well? I don't know how to add code on
excel. Any ideas for me? Please? Thanks!! Jennifer
 
R

Ron2006

Jenniferd,

hmmm. My version of Xcel does that automatically. I opened a new
spreadsheet, typed in an email address. As soon as I got off of it the
address automatically set itself to be underlined and blue in color.
When I put my mouse over it it showed the "Mail to: " format and when
I clicked it it opened an email addressed to that address. My guess is
that it may be some security settings or possibly a version related
issue of Xcel.

I tried but was unable to find anything specific or that changed that
action/process. I know there is an Xcel group here in google Groups
that covers Xcel. You may have to go there and ask that specific
question. I think it is a question of some type of setting in your
version.

Good Luck.

Ron
 

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