How to browse for a file and then store the selected file in 2 text boxes.
====================================================
For older versions of Access try this:
http://www.mvps.org/access/api/api0001.htm
====================================================
This code is a new feature in Access 2002.
It allows you to browse for a file and then store the selected file in 2
text boxes:
Me![txtLocalDir] , Me![txtLocalFileName]
'1 = DialogOpen, 2= SaveAs, 3=FilePicker, 4 = FolderPicker
'Cannot be used in Access 2000!
With Application.FileDialog(3)
.AllowMultiSelect = False
If .Show = True Then
Me![lblEdit].Visible = True
Me![txtLocalDir] = Left$(.SelectedItems(1),
InStrRev(.SelectedItems(1), "\"))
Me![txtLocalFileName] = Right$(.SelectedItems(1),
Len(.SelectedItems(1)) - InStrRev(.SelectedItems(1), "\"))
Me![txtLocalFileName].SetFocus
End If
End With
--
Joe Fallon
Access MVP
Bob said:
I have inherited an Access 200 database that allows users to import three
specific Excel files, interact with data stored in the database and print
reports from the results. The Excel files are called tblData.xls,
tblColumns.xls and tblMisc.xls. Currently, in order to import, the users
need to copy the files to a specific folder, then press a button to import
the three files. What I want to do is to have the button that allows the
user to choose the location of the three files and then imports all three
from that location. This will prevent the users from having to copy files
to a different folder.