Advertisement

12.26.2007 at 09:20AM PST, ID: 23043305
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

Access Hyperlink to open document from form does not work

Asked by jmcdonald69124 in Microsoft Access Database, Access Forms, Access Coding/Macros

Tags: , , , ,

I have searched experts exchange and found the following solution:

Add the module below:

Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&

Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
Declare Function ShellExecuteAPI 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
Declare Function FindExecutable Lib "Shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long


Public Function BrowseURL(ByVal sURL As String)

    Dim lRet As Long, vTaskID As Variant
    Dim sRet As String
    Dim hFile As Long
    Dim sResult As String
    Dim iPos As Integer
    Dim sExplorerPath As String
   
   
   
   
    'First try ShellExecute
    lRet = ShellExecuteAPI(hWndAccessApp, vbNullString, sExplorerPath, sURL, vbNullString, 1)

    If lRet > ERROR_SUCCESS Then
        sRet = vbNullString
        lRet = -1
    Else
        Select Case lRet
            Case ERROR_NO_ASSOC:
                'Try the OpenWith dialog
                vTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
                        & sExplorerPath, WIN_NORMAL)
                lRet = (vTaskID <> 0)
           
            Case ERROR_OUT_OF_MEM:
                sRet = "Error: Out of Memory/Resources. Couldn't Execute!"
           
            Case ERROR_FILE_NOT_FOUND:
                sRet = "Error: File not found.  Couldn't Execute!"
           
            Case ERROR_PATH_NOT_FOUND:
                sRet = "Error: Path not found. Couldn't Execute!"
           
            Case ERROR_BAD_FORMAT:
                sRet = "Error:  Bad File Format. Couldn't Execute!"
           
            Case Else:
        End Select
       
        If sRet <> vbNullString Then MsgBox sRet
    End If
    BrowseURL = lRet & _
                IIf(sRet = "", vbNullString, ", " & sRet)
End Function
***************************************************
Then
add this under the link onclick event on the form.

Private Sub LinkLocation_Click()
'MsgBox Me.LinkLocation.Text & "#" & Me.LinkLocation.Text
browseFiles.BrowseURL Me.LinkLocation.Text

End Sub

*************************************************
It works great but.......
I get a explorer window that goes to the folder that holds the file, it does not try to open the file I have tested with all file types that I will be linking .doc, .pdf, .zip, .exe and none of them work.

Any help on getting the missing link working would be great!!!!

Thanks,

Josh

Start Free Trial
 
Loading Advertisement...
 
[+][-]12.26.2007 at 11:06AM PST, ID: 20530389

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 11:23AM PST, ID: 20530474

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Access Database, Access Forms, Access Coding/Macros
Tags: does, file, form, from, work
Sign Up Now!
Solution Provided By: puppydogbuddy
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628