Browse button

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

Hello Everyone....

Thanks in Advance.....

I have a field on a form called txtFileName.

I would like to be able to create a "Browse" button that
opens an "explorer" type of window (such as open, save as,
etc). I'd like the user to highlight a file, click ok,
(or whatever), which then take the full path of the file
the user selected and then paste into the contents of the
field, without actually opening the file.

Someone suggested the following, which does not work and
seems too simplistic.

Dim strFileName as String
strFileName = Application.GetOpenFileName(,,"Select File
Name:")
Me.TxtFileName = strFileName

Perhaps I need to create a reference to a specific
library, because when I compile it, the method
GetOpenFileName was not found.

Any Help or Insight would be appreciated.

Thanks,
Don
 
"Don" said:
Hello Everyone....

Thanks in Advance.....

I have a field on a form called txtFileName.

I would like to be able to create a "Browse" button that
opens an "explorer" type of window (such as open, save as,
etc). I'd like the user to highlight a file, click ok,
(or whatever), which then take the full path of the file
the user selected and then paste into the contents of the
field, without actually opening the file.

Someone suggested the following, which does not work and
seems too simplistic.

Dim strFileName as String
strFileName = Application.GetOpenFileName(,,"Select File
Name:")
Me.TxtFileName = strFileName

Perhaps I need to create a reference to a specific
library, because when I compile it, the method
GetOpenFileName was not found.

Any Help or Insight would be appreciated.

Thanks,
Don

Don

The safest (ie least likely to break) way of doing this is to use the API call
for the Windows File Open/Save dialog box directly. The code for this is
located on The Access Web at http://www.mvps.org/access/api/api0001.htm.

Whilst this code is complicated, you don't need to understand any of it - just
treat it as a "black box". There is a sample function in there called
GetOpenFile that you can quite easily modify to show certain file types etc.
 
Back
Top