• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

Use a 'browse for file' dialogue box to save a filepath for later use to open in shell

So I have a database where a component is storing the path for documents on a network.  I don't want to use the attachment feature because it makes the database incompatible with 2003 and makes the database size much larger.
Instead, I'd like to have a command button where the user will use explorer to define the path and then save this path in a field 'FilePath' The FilePath will then be able to be opened at a later time.
Could anyone show me an example of how to use this feature in Access?

Thank you,
2 Solutions
Using the application object
Function GetFolder(strPath As String) As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
    .Title = "Select a Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath
    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
End With
GetFolder = sItem
Set fldr = Nothing
End Function

Open in new window

You'll need a reference set to the Microsoft Office x.0 Object Library (Microsoft Office 12.0 Object Library on my unit) to make this play.
You'll need to change msoFileDialogFolderPicker  to  msoFileDialogFilePicker to select a file rather than a folder, too
BevosAuthor Commented:
Thanks a lot, both you!

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now