• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 99
  • Last Modified:

How to create a hyperlink to an Outlook 2010 ".msg" file in an Access linked SQL Server table?

I'm trying to open a ".msg" outlook file saved on a hard drive from a Microsoft Access form with it's recordsource being a linked SQL Server 2012 table. If I doubleclick the file in Windows Explorer it opens via Microsoft Outlook. I set the form textbox as a hyperlink but I can't set the data type of the field to hyperlink in Ms Access.
1 Solution
On the form, add a button.In Command Button Wizard, choose Application, then Run Application (this from Access 2003)  Make up one and get to finish. It will open a code window with something like:
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click

    Dim stAppName As String

    stAppName = "abc"
    Call Shell(stAppName, 1)

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command7_Click
End Sub

Open in new window

Replace all of that code with this, but replace the line it that says,
"Private Sub Open_Click()" with whatever your button name was. Example from code generated above
would be:
"Private Sub Command7_Click()"

Option Compare Database

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 lpnShowCmd As Long) As Long

Private Sub Open_Click()
On Error GoTo Err_Open_Click

    ShellExecute 0, "open", txtDocPath.Value, 0, 0, 1

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Open_Click
End Sub

Open in new window

You may have to tweak it in the code, but it works for me.

Also it expects a textbox named txtDocPath. If yours has a different name you will need to change that in this code to match.
pabrannPresidentAuthor Commented:
Worked like a charm, thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now