0
Private Sub bBrowse_Click()

  Const msoFileDialogFilePicker As Long = 3
Dim objDialog As Object

Set objDialog = Application.FileDialog(msoFileDialogFilePicker)

With objDialog
    .AllowMultiSelect = True
    .Show
    If .SelectedItems.Count = 0 Then
        MsgBox "No file selected."
    Else
        Me.[File Link].Value = Dir(.SelectedItems(1))
    End If
End With

End Sub

I was able to get it to add in the cell I need it to but it when it is clicked it will not open the file or path

Andre
  • 26,751
  • 7
  • 36
  • 80
Daniel K
  • 1
  • 1
  • https://stackoverflow.com/questions/9476268/filedialog-doesnt-work?answertab=oldest#comment17467925_9476268 I am using this code but I need to add the full path to the file – Daniel K Dec 02 '17 at 19:20
  • [ask] -- please explain what you want to do, and what exactly doesn't work. – Andre Dec 02 '17 at 19:52
  • Hi Andre, I am trying to link a file into a shared drive. Once it is added to the record. Another person can click the link and open the file. I can not use attachments due to the quantity of items that will come through. It shows the file name at the moment but I can not open it. I think it is adding only the file name and not the path. – Daniel K Dec 02 '17 at 20:30
  • For future questions: don't add relevant information in comments, edit your post instead and add it there. – Andre Dec 03 '17 at 09:03

1 Answers1

0

Please read this: Debugging VBA Code
to learn how to step through code and inspect variables.

.SelectedItems(1) already contains the full path, but Dir(.SelectedItems(1)) returns only the file name. So remove the Dir().

Now to actually open the file from a record, you need additional code e.g. in a button next to the File Link textbox, or in its DblClick event.

See here: Open Hyperlinks in Access

Community
  • 1
  • 1
Andre
  • 26,751
  • 7
  • 36
  • 80