Kamis, 09 Mei 2013

[MS_AccessPros] Allowing a user to select a file and insert a hyperlink to the file

 

I'm trying to create a command button on a form that allows a user to browse to a file and once selected, insert the hyperlink to the file.

The hyperlink address needs to be saved in a field called: txtFlaggedDocumentLink (which is a hyperlink field).

I've pieced together the following after searching the web, however, while the path to the filename is saved correctly, when I click on the link, it doesn't work. It appears to be a hyperlink, but it won't work.

Private Sub cmdFindFile_Click()
'Sub getFileName()
' Displays the Office File Open dialog to choose a file.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(1) ' 3 is a constant: msoFileDialogFilePicker
.Title = "Select File"
.Filters.Add "All Files", "*.*"
.FilterIndex = 1
.AllowMultiSelect = False
'.InitialFileName = CurrentProject.Path
' This opens the NCQA library folder to start the search.
.InitialFileName = "\\Rmregfile017\ncqalibrary"
result = .Show
If (result <> 0) Then 'result = 0 if nothing was selected
fileName = Trim(.SelectedItems.Item(1))
'filename contains the path you want.
Me.txtFlaggedDocumentLink = fileName

End If
End With

End Sub

Any suggestions?

I also tried,

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar