Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse for file

Status
Not open for further replies.

northernbeaver

Programmer
Jul 9, 2001
164
0
0
CA
I seem to have a bit of a problem. I am running ms access 2000 and I need to offer a way for the client to browse for a file and store the path into a field in a table. I have searched Tek-Tips and have found the following. I dont seem to have the active X for the common dialoge box and the Application.FileDialog doesnt seem to be a valid option. is there another way?
 
#1 Be wary of having to rely on controls and tools that may (obviously) not be standard in your environment. You'll have to distribute and install and maintain all of that.

#2 The FileSearch object is very useful ... but it can really slow things down ... it's not too bad if you can count on them searching in a particular folder for a file that's presumed to exist ...

Check your help file for FILESEARCH OBJECT. I think the FILESEARCH object is all you need. It's part of all office products.

Alan J. Volkert
Fleet Services
GE Commercial Finance Capital Solutions
(World's longest company title)
Eden Prairie, MN
 
I'm with danvlas,

the filedialog wasn't available until the 2002 version, the common dialog provide has it's distribution problems (commonly referred to as "DLL Hell", I think), so the API is probably the most reliable solution for this challenge.

Roy-Vidar
 
The Open/File dialog method described in the link is available in all Windows versions, regardless of Office being installed or not. It's just Windows API.

FileSearch object may be disabled by turning off Windows Scripting Host and if so, it won't work.

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
danvlas,
not that I use FileSearch much, but isn't that a member of Access.Application? Would you be thinking of methods of FileSystemObject (Scripting Runtime/Windows Script Host)?

Roy-Vidar
 
thanks for your help guys I have used the code that was on the link Danvlas gave me. here is my interesting Dilema. on one form I ask them to show me where the file is. that info is saved to a table. on another form that will be used by external clients, I want the client to click on a button and then be prompted to save the file (that was listed in the table) to their local hard drive. any ideas how I would accomplish this?
 
The following function can be called as follows:

strFilename = FindPicture().

It opens a dialog box which lets you select a specific file and returns the Absolute path of the file, which you can then put into your table aa a pointer.

I've left a lot of options in there as comments to demonstrate how this function can be modified or adapted for other purposes.

-------------------------------------

Public Function FindPicture() As String



With Application.FileDialog(msoFileDialogFilePicker) 'Grab copy of the Office file dialog (pick files)
'With Application.FileDialog(msoFileDialogFolderPicker) 'Grab copy of the Office file dialog (pick folders)
.AllowMultiSelect = False 'Select only one file
.Title = "Locate picture file" 'Set dialog title
.ButtonName = "Choose" 'Set the button caption
'.Filters.Clear 'Make sure the filter list is clear
'Add 2 filters
'.Filters.Add "JPEGs", "*.jpg"
'.Filters.Add "Bitmaps", "*.bmp"
'.FilterIndex = 2 ' Set the filter index to 2
'.Filters.Add "All", "*.*"

'Set initial path

.InitialFileName = "C:\Documents and Settings\" 'Initial file search location

'Show files as thumbnails
'.InitialView = msoFileDialogViewThumbnail
.InitialView = msoFileDialogViewList

'Show the dialog and test the return
If .Show = 0 Then
'didn't pick a file - exit sub
Exit Function
End If

'Should be only one file name - grab it
FindPicture = Trim(.SelectedItems(1)) 'Full path of picture

'On Error Resume Next 'Set error trap

End With



End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top