Open Folder using explorer

Posted on 2009-04-29
Last Modified: 2012-06-21
Hi Experts

I am running access 2003 and have a form which I want to add a command button to that opens up a folder (using explorer).  

The file path for the folder will change from record to record.  But as part of the set up process for each record, a folder is created in the following filepath U:\CDG\CDG\Members Folders\ & then has a sub folder derived using the following naming protocol [First Name]-[Last Name]-[ID] (i.e. Dave-Smith-123)

So the link piece to the code would be U:\CDG\CDG\Members Folders\[First Name] & "-" &[Last Name]& "-" & [ID]

Has anyone got a piece of code to do this or can anyone help?
Question by:correlate
    LVL 119

    Accepted Solution


    place this in the click event of the button

    dim spath as string
    spath="U:\CDG\CDG\Members Folders\[First Name] & "-" &[Last Name]& "-" & [ID]"

    followhyperlink sPath
    LVL 11

    Expert Comment

    The code to simply open a folder using explorer is:

    Application.FollowHyperlink "U:\CDG\CDG\Members Folders\"

    The rest can be achieved by cycling through or looking at a recordset to gather and concatenate the first/last name and IDs to create the entire folder location (assuming this is available in a table or query).

    Hope that helps,
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    Here is the generic Shell:

    Shell "explorer.exe  U:\CDG\CDG\Members Folders\", vbNormalFocus


    Author Closing Comment

    Perfect thank you,

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    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…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    754 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

    17 Experts available now in Live!

    Get 1:1 Help Now