View Full Version : Brows for file button


chris_visible
01-17-2002, 05:47 AM
Is it possible to create a button that allows a user to open a find file window to select a file, with the location being pasted into a text box on an access form.

If this is possible I would love to know how. If it is not possible I would like someone to tell me.
Please help
Thanks

raindrop3
01-17-2002, 06:02 AM
It is possible. Search this forum for 'browse file' or something.

You had to use the CommonDialo control. Use the following code to open it an to put the path in a textbox:


CommonDialog1.CancelError = True 'CommonDialog1 is the name of the CommonDialogControl
On Error GoTo ErrHandler

' Set flags & filters:
'CommonDialog1.Flags = cdlOFNHideReadOnly
CommonDialog1.Filter = "All Files (*.*)|*.*|JPG files" & _
"(*.jpg)|*.jpg|MDB files (*.mdb) |*.mdb"


' Specify default filter
CommonDialog1.FilterIndex = 2

' Display the Open dialog box
CommonDialog1.ShowOpen

filename11 = CommonDialog1.filename 'put the path in the string filename11
'path.SetFocus
path = filename11 'put the string in a textbox.
Exit Sub

ErrHandler:
'User pressed the Cancel button
Exit Sub

Greetings,

Albert

chris_visible
01-17-2002, 07:15 AM
Thanks very much. I will try that now. If I have any problems I will post them back here.
Thanks again

chris_visible
01-17-2002, 07:37 AM
I dont think I have the CommonDialog Control in my visual basic 'References Library'.
What is the easist way to make it available?

Thanks

raindrop3
01-17-2002, 10:35 PM
Hello,

I have the following references:

- Microsoft Common Dialog control 6.0
File: comdlg32.ocx

Albert