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

Posted on 2011-05-06
Last Modified: 2012-06-27
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,
Question by:Bevos
    LVL 42

    Accepted Solution

    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

    LVL 26

    Assisted Solution

    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

    Author Comment

    Thanks a lot, both you!

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now