Hyperlink in a form (1 Viewer)

Issy

New member
Local time
Today, 01:28
Joined
Nov 17, 2007
Messages
2
My database is for customers details.

I have created a form (from a table) in which two fields are hyperlinked. One field is the web address and the other one is the email address.

The email field is not working properly: Instead of opening the email, it opens the web page for the customer.

When I edit the hyperlink, I can see that it is linked to the box at the top saying "Existing file or web page". I can edit each customer's details one by one so that the "email address" box at the bottom is selected then I copy and paste the email address which add the "mailto" bit and Access recognizes that it is an email address.

BUT I have 1000+ customers in this database and do not want to edit their details individually.

Question 1: Why is Access not automatically selecting the "E mail address" (in the editing hyperlink window)?

Question 2: I would like to be able to change this setting easily and not have to edit each customer's details individually. What can I do? :(
Please help.

Thank you. :)
 

ansentry

Access amateur
Local time
Today, 10:28
Joined
Jun 1, 2003
Messages
995
1> Change the data type (in the table) of your email address to text.

2> Put the code below behind the OnClick event of the email control on the form.

3> Change this in the code to suit. .To = cusEMail (change cusEmail to the name of your control)


Code:
Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)


With outMsg
    .To = cusEMail
    '.CC = cusCC
    '.BCC = cusBCC
    '.Subject = cusSubject
    '.Body = cusEmailBody
    .Importance = olImportanceHigh
    .Display
End With
    
Set outApp = Nothing
Set outMsg = Nothing


In the code you will see items under With that have ' in front of them. You can use these in your form by adding the files to the table and then adding them to your form, after you have done that remove the ' from the code.

Hope this helps, if not post back.
 

Issy

New member
Local time
Today, 01:28
Joined
Nov 17, 2007
Messages
2
Hyperlink in Form

Thank you for taking the time to answer. Will try that. Issy, UK:)
 

DavidRS

Registered User.
Local time
Today, 01:28
Joined
Jan 4, 2005
Messages
43
Hyperlink in form

I found this earlier and it seemed to be what i was looking for. Like Issy, I have a number of contacts with email addresses. Upto now, I've had to merge to word then send from there but that's becoming a pain. I want to be able to directly from the record including the subject title taken from the record.

I've tried copying the code into my form and I've changed the To & Subject lines as appropriate but when I try to create the email, I get an error message saying: "Compile Error: User-defined type not defined". I've tried changingh a few options but still getting the same message.

The code in mine is:

Private Sub Email_DblClick(Cancel As Integer)
Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)

With outMsg
.To = Email
'.CC = cusCC
'.BCC = cusBCC
.Subject = Request_Title
'.Body = cusEmailBody
.Importance = olImportanceHigh
.Display
End With

Set outApp = Nothing
Set outMsg = Nothing
End Sub

"Email" & "Request_Title" are the fields from my form

The trouble-shooter is highlighting the first row suggesting the problem is there.

Where have I gone wrong?
 

ansentry

Access amateur
Local time
Today, 10:28
Joined
Jun 1, 2003
Messages
995
Go into your code screen (Alt+F11), from tools click references and then find Microsoft Outlook xx.x Object Library and select it.

xx.x is because I don't know what version of Outlook you are running, mine is 2003 and therefore it is 11.0
 

DavidRS

Registered User.
Local time
Today, 01:28
Joined
Jan 4, 2005
Messages
43
Cheers matey,

It's worked a treat and I just wish I had thought about it earlier!:)
 

Users who are viewing this thread

Top Bottom