Insert File Path

Dylan Snyder

Registered User.
Local time
Today, 14:14
Joined
Dec 31, 2007
Messages
89
I need to insert the file path into a text field on a form. The user should be able to click on the field on the form and a dialog box appear that allows the user to selct the file. I have tried using Terry Kreft's code and inserting into a module, but it is not clear what the next step is to integrate into a form. Has anyone had any success using this before?
 
hi dylan,

there are easier way to do it. if you have Access 2000 or later, then following code should work if you put it in the Click event of the text box,e.g for a textbox called txtFileName:
Code:
Private Sub txtFileName_Click()
    Dim fdlg As FileDialog
    Dim sFile As String

    Set fdlg = Application.FileDialog(msoFileDialogFilePicker)
    
    With fdlg
        .AllowMultiSelect = False
        If .Show Then
            sFile = fdlg.SelectedItems(1)
            txtFilename.value = sFile
        End If
    End With
End Sub

HTH,
Chris
 
Thanks a lot. Appreciate it
 
Last edited:
Or you could of course, not reference the library but use these 2 lines instead:
Code:
    Dim fdlg As Object
    
    Set fdlg = Application.FileDialog(3)
 
Success! Thanks for all of your help! I guess we didn't install all of the appropriate libraries when we movede to '03.
 

Users who are viewing this thread

Back
Top Bottom