I'd like to add a "Browse" button to an MS Access 2007 form that will bring up a standard Windows file browser (as a modal window) and allow the user to select a directory. When the user OKs out of that browser, the path the the selected directory should be written to a text box in the Access form.
What's the best way to do this? Is there a native Access way?
Create a function which uses
Application.FileDialog
. TheFileDialog
is modal.This function will return the user's folder selection if they made one, or an empty string if they clicked cancel on the
FileDialog
.I think you can use that function in your command button's click event.
If you're concerned that Microsoft may remove the
FileDialog
object from Office someday, you can use the Windows API method instead: BrowseFolder Dialog.