Roselene 09-15-2000, 07:58 AM Hi, folks!
I'm trying to create a form where the users must enter the name of a file.
In order to avoid typing mistakes, I'd like the user to be able to choose the file on a listbox (or some other object), instead of having to type all the path and the file name...
I also would like the user to be able to look for the file by clicking on folders, in a similar way to when we use the "open file" command of Word or Excel.
Then, the choosen file name would be recorded in a table.
Is that possible in VB?
Thanks in advance for any help, Roselene
:)
Valkyrie 09-15-2000, 08:49 AM On the Menu Bar choose Project and them Components. Click Microsoft Common Dialog Manager so that the check box is lit, click apply and then you can place the object on your form.
Once it is there you can right click on it to get the properties and then you can use various methods to open for Saving or Opening a file. If you need a code snippet to get you going lemme know!
HTH.
Quote of the moment....
"My job is so top secret even I don't know what I'm doing!"
JenniferD 10-16-2002, 11:36 AM I have been searching this site for code how to open a 'select file' dialog box, but haven't found anything quite right yet. an anyone help? This post had similar stuff, but I guess it was for VB cause I don't have a 'Project' menu option anywhere.
Thanks,
Jennifer
GMan_NC 10-16-2002, 11:39 AM JenniferD, go to your code window
Select Tools then References
Scroll down until you see Microsoft Common Dialog Control
Select that
JenniferD 10-16-2002, 11:44 AM I appears I do not have that reference.......more suggestions?
GMan_NC 10-16-2002, 11:46 AM in the References Window, click the browse button and look for
Comdlg32.ocx
it should be in the system or system32 folder
JenniferD 10-16-2002, 12:02 PM GMan_NC,
THanks for your patience, i found it that way.
Now what?
Jennifer
GMan_NC 10-16-2002, 12:10 PM That's a loaded question Jennifer :)
You'll need to add the common dialog activex control to a form
then you'll need a button to open the dialog
then you'll have to decide what you want to do with the filename that is selected.
example code
Private Sub cmdOpen_Click()
On Error GoTo Err_Open
axOpen.ShowOpen 'axOpen is the activex control
txtFileName = axOpen.FileName
Exit_Open:
Exit Sub
Err_Open:
MsgBox Err.Description, critMessage, "Open File " & Err.Number
Resume Exit_Open
End Sub
UncleSam 10-16-2002, 12:18 PM commondialog1.filename will be the file he chose
you can get all at www.msdn.microsoft.com
JenniferD 10-16-2002, 12:19 PM You make it sound so simple. I went to select the Active X coponent from the tools bar and i got this message:
You don't have trhe liscense required to use this Active X control.
TO obtain the appropriate lisence, contact the company that provides the lisences OLE object or Actie X control.
Next suggestion?
boy, this just isn't my day!
jennifer
UncleSam 10-16-2002, 12:25 PM you just want a commondialog something to open a file or not like in wrd or xls or not?
GMan_NC 10-16-2002, 12:26 PM And here I was thinking it WAS simple :) just kidding.
Not sure what the problem is there. I guess we need to know what version of Acces you are running, what operating system you have and maybe the version number on comdlg32.ocx
UncleSam 10-16-2002, 12:27 PM **** it didnt see you were using access thought you were using vb cause in vb it would have been simple but cause vba is so close it should work
JenniferD 10-16-2002, 12:36 PM I am trying to do this at work in a big corporation, so maybe there are file permissions or something funky happening here. I will try it at home tonight and see if i get the same error. Here at work I am running Access 2000 on Windows 2000 Professional. At home I have Access 2000 on Windows 98. The COMDLG32.OCX is dated 5/7/1999, 137k, version 6.0.84.18 if that helps.
I will let you know tonight or tomorrow if I run into the same problem....
thanks for all of your help!
JenniferD 10-17-2002, 10:57 AM I was able to get the CommonDialog box working at home. I didn't have time to play with it, but I was able to put it on a form without any errors. Thanks for your help. I am sure i will have other questions.
Jennifer
|