Open File dialog in VBA

Hi,

I want to have a user in an Access 2000 application to select a file on the hard disk. For this purpose, I'd like to use the standard Windows "open file" dialog. I seem to recall some method in VB 5 that sounded like OpenFileDialog or so, but can't find anything like it in VBA. Where should I look?
thanks
TomdpAsked:
Who is Participating?
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.

tkuppinenCommented:
You need to add a common dialog control.  This will give you access to the open file dialog box.
0
TomdpAuthor Commented:
Well, that's exactly the problem. I referenced "windows common controls" but don't see any file dialog box or so available. I'm looking for some code, really :)
0
believerCommented:
Check out this previously asked question.

"Free OCX Controls" - http://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=10216659 
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

tkuppinenCommented:
Sorry, I guess I was thinking of the VB way to do this.  Why is it so much harder to use windows controls in Access?
0
tomk120999Commented:
Tomdb, 2000 has changed a mite, but not much, from '97.

The method (in VBA) you need is RunCommand of the DoCmd object.  Here's what Help says:

You can use the RunCommand action to run a built-in Microsoft Access command. The command may appear on a Microsoft Access menu bar, toolbar, or shortcut menu.

Check that out in the Help and you should be set.  To find out what the options are, open a new macro sheet and select the RunCommand Action in the top pane, then explore the options in the bottom pane.  I think it will look like this in a VBA module:
DoCmd.RunCommand acCmdOpenFile
 or acCmdFileOpen
That should open the ACCESS file open dialog for the user.
0
dtomynCommented:
The best and most reliable way to do this is via an API call.  The code to do this can be seen at: http://www.mvps.org/access/index.htm
 ... under the API section (it is the first one listed)

0

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
BrianWrenCommented:
Say Tomk:  How about proposing your answers as comments, instead of locking the questions will partial answers and guesses?  Tomb, if I were you I would reject Tomk's proposed 'answer,' since it really isn't.

I have had bad luck with the Common Dialog ActiveX object.  It's easy to use, hard to distribute.

API calls ar ethe way to go.  It gives you complete control over all the aspects, and makes you feel like a hero when it works.

The web site dtomyn recommended is outstanding!

Your solution can definitely be found there.
0
TomdpAuthor Commented:
Tomk, I don't want to open an access database (as your method suggests), I just want the open dialog box to have a user select a file. My code will open it
0
TomdpAuthor Commented:
Totally wild website indeed. Should have kept it for yourself :)
0
dtomynCommented:
Tomdp,
Yeah, that site is excellent and will allow you to get a bunch of expert points in this Access topic area if you hang around here long enough (and obviously if you have time).  The problem with keeping it "secret" (I am sure there are a number of experts that use that site as well) is that it is hard to give credit where credit is due on code that you post.  That is, I am always hesitant to post code that I obviously did not create myself, yet not give the credit to the site where I got it from.
0
tomk120999Commented:
brianwren, Thanks for the comment, I got another such and appreciate them.  However that wasn't a guess since I've used the technique many times in VBA, In VB the common dialg box control is the one.  Stay on me, I'll develope some manners!

good luck as usual...
0
tomk120999Commented:
brianwren, Thanks for the comment, I got another such and appreciate them.  However that wasn't a guess since I've used the technique many times in VBA, In VB the common dialg box control is the one.  Stay on me, I'll develope some manners!

good luck as usual...
0
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.