email address as a data field

  • Thread starter Thread starter John Milbury-Steen
  • Start date Start date
J

John Milbury-Steen

Hi Access gurus,
How do you define an email address field so that you click on the email
address and it activates your email program? Would this be an OLE object?
A hyperlink? Would the data have to appear as
mailto: (e-mail address removed)? Getting this to work would really be welcome at my
office!
 
You can use the ShellExecute code (it's actually VB, but I've been told
it'll work in Access aswell).

'BEGIN
'Declarations
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long

'Form Code
Dim strAddress As String
strAddress = <code for your fields go here>

ShellExecute hwnd, "open", "mailto:" & strAddress, vbNullString,
vbNullString, vbNormalFocus
'END

Or you could always use CDO, CDONTS, MAPI and the likes?.

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk
 
John Milbury-Steen said:
Hi Access gurus,
How do you define an email address field so that you click on the email
address and it activates your email program? Would this be an OLE object?
A hyperlink? Would the data have to appear as
mailto: (e-mail address removed)? Getting this to work would really be welcome at my
office!

You *can* define it as a hyperlink field, but I find that causes all sorts
of complications as Access then really wants to interpret the field as a web
address. What I do is define the field as a text field, and then in a
double-click event I tack "mailto:" on the front of the field's value and
use Application.FollowHyperlink to open an e-mail message to that URL.
Along these lines:

'--- start of sample code ---
Private Sub txtEmail_DblClick()

If Not IsNull(Me.txtEmail) Then
Application.FollowHyperlink "mailto:" & Me.txtEmail
End If

End Sub
'--- end of sample code ---
 
Back
Top