Hyperlink to hard drive issues

Healey33

New Member
Joined
May 28, 2012
Messages
19
Hey, I am using Access 2010 on a cloud network.

I am having trouble with my hyperlink field to a pdf document located on a cloud drive. 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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Is it possible that the problem originates from using the path K:... instead of the UNC? If the K Drive is a cloud drive as you say, then I would assume that it is acting like a server, and if so using the UNC instead of the path that you showed might be a solution. Not 100% sure if this is the cause or not.
 
Upvote 0
The hard disk drive is the location on our computer where the applications, files, folders and other data are permanently stored. The hard disk drive can store enormous amounts of information. For each application that is open, data is accessed from the hard disk to the random access memory (RAM) for rapid processing. When the application shuts down, the changes if any are stored in the hard disk drive and the space in the RAM is released for other applications.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top