Lock Access dialogbox to a certain directory

Is it possible to stop the user from changing the path that comes up in the dialogbox and not allow them to change it? Or at least only drill down into it.
Chuck LoweAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
we can set the default directory when the dialog box open, but we can not prevent the user from moving away from that directory.
Chuck LoweAuthor Commented:
I know I can set it to a certain directory and I did. I'm guessing the only way to stop them is to do my own listbox and fill it (DIR command) with the files I find.
You can't prevent them from navigating but you can verify the path before you act on the selection.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
Not sure what your ultimate goal is here.

So please consider the Expert's posts above...

If your goal here is to set a certain top level folder that users can select a file from, ...then you can "List" all the files in a specific folder, and let the use select the file(s) from a listbox.
Basic code would look something like this:
'Sets the Folder path/Name
Const strFolderName As String = "C:\YourFolder\"

Private Sub Command8_Click()
'Clear the form
    'Call the sub that lists the files
    Call ListFiles
    'Clear the textbox
    Me.Text6 = ""
End Sub

Private Sub Form_Open(Cancel As Integer)
    'Call the sub that lists the files
    Call ListFiles
End Sub
Sub ListFiles()
'List the files
Dim strFileName As String
Dim strFileList As String

strFileName = Dir(strFolderName & "*.jpg")

While Len(strFileName) > 0
    strFileList = strFileList & strFileName & ";"
    strFileName = Dir()

Me.lstFiles.RowSource = strFileList

End Sub

Private Sub lstFiles_AfterUpdate()
    'Display the full FileNme
    Me.Text6 = strFolderName & Me.lstFiles
End Sub

Open in new window

In this way, they cannot ever navigate away because the path is set and you are not using the windows explore interface.
The downside here is that this cannot easily be made to allow user to drill down to other folders.
It will also not "look like" that standard file dialog box.
But calls for something like this are very popular nonetheless.

With these drawbacks in mind, I am just posting it here as an FYI, perhaps you can glean something useful from it.


Chuck LoweAuthor Commented:
That is exactly what I decided to do. I did try writing a custom dialog box but I had issues with letting them drill down. Although I will use the custom box when they are only to stay in one directory.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.