MS Access: Open specific directory from field criteria

Posted on 2011-10-03
Last Modified: 2012-05-12
I am familier with the code for opening an explorer directory from MS access, but I need to take it one step further.  I would like to be able to use the data from a field as criteria in the string for opening the directory.

For example:
I have a form with a feild for SSNs.  I also have a directory with folders named specific SSNs.  I would like to have the code below use the current recordset and open the folder that matches the data in the field.  

Is it similar to using a field for a parameter query [forms]![frmSomeForm]![SomeField]......?

Private Sub openDirectory_Click()

    Shell "explorer.exe C:\ScannedFiles\........", vbNormalFocus

End Sub

Any help is greatly appreciated!
Question by:DerFuzh
    LVL 119

    Expert Comment

    by:Rey Obrero

    Shell "explorer.exe C:\ScannedFiles\" & [forms]![frmSomeForm]![SomeField], vbNormalFocus
    LVL 119

    Accepted Solution

    if the button is on the same form

    Shell "explorer.exe C:\ScannedFiles\" & Me.[SomeField], vbNormalFocus

    you can also use

    followhyperlink  "C:\ScannedFiles\" & Me.[SomeField]
    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    Really, you have folders named with the value of SSNs?  

    Hope you are prepared for the lawsuits that will accompany that when someone who shouldn't have access to the server gets access.

    Author Closing Comment

    EXCELLENT!  Thanks capricorn1 for the speedy response!  It's just what I was looking for!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    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…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    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…

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now