Results 1 to 3 of 3
  1. #1
    healey33 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    10

    Question Hyperlink Issues

    Hey, I am using Access 2010 on a cloud network.

    I am having trouble with my hyperlink field to a pdf document. The user sets the hyperlink themselves by clicking btnGetLink and searching for the file. When the user selects the file, the hyperlink is put in the txtLink text box which is bound to my table. The hyperlink in the text box works fine when copied into windows explorer (when I go to edit hyperlink and select the hyperlink, not the actual text in the text box) but clicking on the hyperlink itself yields an error message "An unexpected error has occurred". Here is a sample hyperlink address: "K:\Common\User\David\Signed Leases\Lease528.pdf" The K: drive is the cloud network drive which I am also running access off of.

    This is the code:

    Code:
    Private Sub btnGetLink_Click()
    Dim strButtonCaption As String, strDialogTitle As String
    Dim strHyperlinkFile As String, strSelectedFile As String
     
    'Define your own Captions if necessary
    strButtonCaption = "Save Hyperlink"
    strDialogTitle = "Select File to Create Hyperlink to"
     
    With Application.FileDialog(msoFileDialogFilePicker)
      With .Filters
        .Clear
        .Add "All Files", "*.*"     'Allow ALL File types
      End With
      'The Show Method returns True if 1 or more files are selected
        .AllowMultiSelect = False       'Critical Line
        .FilterIndex = 1 'Database files
        .ButtonName = strButtonCaption
        .InitialFileName = "K:\Common\User\David\Signed Leases"
        .InitialView = msoFileDialogViewDetails     'Detailed View
        .Title = strDialogTitle
      If .Show Then
        For Each varItem In .SelectedItems 'There will only be 1
          'Display Text + # + Address of Hyperlink (Display Text#Hyperlink Address)
          strSelectedFile = varItem
          strHyperlinkFile = fGetBaseFileName(strSelectedFile) & "#" & strSelectedFile
          Me![txtLink] = strHyperlinkFile
        Next varItem
      End If
    End With
    
    
    End Sub
    
    
    Public Function fGetBaseFileName(strFilePath As String) As String
    'This Function accepts the Absolute Path to a File and returns the Base File
    'Name (File Name without the Extension)
     
    'Make absolutely sure that it is a valid Path/Filename
    If Dir$(strFilePath) = "" Then Exit Function
     
    Dim strFileName As String
    Dim strBaseFileName As String
     
    strFileName = Right$(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
     
    strBaseFileName = Left$(strFileName, InStr(strFileName, ".") - 1)
      fGetBaseFileName = strBaseFileName
    End Function
    If anyone could provide some assistance as to why clicking the hyperlink yields an error message, that would be great!

    Thanks



    **I did not write this code. It is from http://bytes.com/topic/access/insigh...hyperlink-form

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,948
    I suggest you first test the code with a local drive, such as the C: on your computer.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    healey33 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    10
    Thanks for the reply. I figured it out. Since it was on a cloud drive, I had to use UNC referencing.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 05-07-2012, 06:11 PM
  2. help with hyperlink
    By bmd in forum Access
    Replies: 1
    Last Post: 08-24-2011, 12:41 PM
  3. Hyperlink Builder Issues - Paths vs Parameters
    By JeffG3209 in forum Programming
    Replies: 0
    Last Post: 08-16-2011, 02:17 AM
  4. Replies: 4
    Last Post: 01-31-2011, 03:19 PM
  5. Hyperlink Help
    By smikkelsen in forum Access
    Replies: 9
    Last Post: 03-12-2010, 11:28 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums