tags:

views:

47

answers:

3

i have an access program which i have been working on and i want to create a openFileDialog which will show specific folders and files. For e.g. when you click a button, instead of having the dialog showing all the folders and files, it will be given a parameter (folder name) and it will show only that folder. i am trying to achieve something similar to the windows search engine. the reason is that, my program has a folder which contains around 1000 sub folders which contain a documents. each subfolder has the same name as the document it contains. therefore, what i an trying to achieve is that from my Access Form, the user can click a button, and a dialog will pop up showing only the folder which contains the document the user is working on.

is this possible.

i would really appreciate your help thank you

+1  A: 

Do you mean you want OpenFileDialog to start in a specific folder?

You can do it like this:

OpenFileDialog MyOpenFileDialog = new OpenFileDialog();
MyOpenFileDialog.InitialDirectory = "C:\Path\To\My\Selected\Subfolder" ;
MyOpenFileDialog.ShowDialog()
Colin Pickard
I think you must be leaving out a lot of code, as OpenFileDialog() is not a built-in Access object, nor an object that is in any of the default Access or Office libraries. You either need a bunch of code you've ommited or some reference you haven't mentioned.
David-W-Fenton
you may be right there, this generic .NET, I was making the assumption the OpenFileDialog mentioned by the question asker was the same call - I haven't tried it.
Colin Pickard
A: 

Access provides Application.FileDialog. If you want to use the ENUM for the dialog type, you'll have to add a reference to the Office Object library, but if you try to use the enum you'll get prompted and Access will add the reference for you. It's not much use, though, as it can otherwise be used quite easily with object variables instead of strongly-typed variables.

To learn how to use it, open the Immediate Window (Ctrl-G), type Application.FileDialog, and hit F1. That explains the basics.

For what it's worth, I was using Windows API code from the Access Developers Handbook before the Application.FileDialog was introduced (with A2002), so I continue to use that. I am pretty sure the functionality is identical, though Application.FileDialog probably has a spiffier interface (I don't know -- I don't use it!).

David-W-Fenton
A: 

thanks for the replies guys but i think you i was not clear enough. I want a openDialog to open up but the path that its going to point is not fixed but variable. e.g. i have a folder called TEST which is c:/Users/TEST and in this folder i have 100 subfolders with names test1,test2,test3....test100. So i want the openDialog to open the TEST folder but show me the only subfolder that the user is going to provide from the form.SO, if i want subfolder test50 then in my form am going to type in the textbox test50 and click the OPEN button which will pop up the openDialog where only test50 folder will be shown.Something like a search thing i am trying to achieve.

Hope this clears it up guys.

Thanks a lot,,really appreciate your help

kiril
Have you looked at Application.FileDialog inside of Access? It's not clear to me that it allows you to set the starting folder or not. The Windows API file dialogs will allow you to do this, and code for those are available at http://www.mvps.org/access/api/api0001.htm and http://www.mvps.org/access/api/api0002.htm (the last is browse for folder, probably not what you're looking for, but included for completeness).
David-W-Fenton