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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 97 - File Selection 2

Status
Not open for further replies.

stephenj789

Technical User
Jan 28, 2002
58
US
I have a form in Access that looks something like this:

|Form|-----------------------------------|
|
| |Button| |.......Text Box.......|
|
|
|------------------------------------------|

What needs to happen is this: When the user presses the button, an open dialog box allows the user to navigate to a file. Once the file is selected by the user, the file name and path will be located in the textbox, like this:

|Form|-----------------------------------|
|
| |Button| |C:\Temp\MyFile.txt...|
|
|
|------------------------------------------|


and that is it. If there is an simple way to do this, I would much appreciate knowing it. Thanks in advance.
 
Do a search Stephen, lots of posts in this forum, on that subject...
 
I found the following:

Code:
Function PickFolder(strStartDir As Variant) As String
'Prompts you to pick folder, then returns the path
    Dim SA As Object, f As Object
    Set SA = CreateObject("Shell.Application")
    
    Set f = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
    If (Not f Is Nothing) Then
    
        PickFolder = f.Items.Item.Path
       
    End If
    Set f = Nothing
    Set SA = Nothing
End Function

Which almost does what I want it to. It gives me the directory path, but not the file name.
 
I've already posted this too:
Code:
Function PickFile()
Dim F As Object
Set F = CreateObject("SAFRCFileDlg.FileOpen")
F.OpenFileOpenDlg
PickFile = F.FileName
Set F = Nothing
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
or this (just for the record).
make reference to MS Office Object Library.
...you may want to modify, to suit your needs.





Public Function OpenFileDialog() As Variant
'Opens File Dialog
Dim FileDialog As FileDialog
Dim vFileSelected As Variant, x As Integer

Set FileDialog = Application.FileDialog(msoFileDialogOpen)

If FileDialog.Show = -1 Then
For Each vFileSelected In FileDialog.SelectedItems
OpenFileDialog = OpenFileDialog & ";" & vFileSelected
x = x + 1
Next vFileSelected
Else
MsgBox "nutin' selected,bro?"
End If

Set FileDialog = Nothing
OpenFileDialog = Mid(OpenFileDialog, 2)

End Function
 
Thanks for the help PHV and Zion7. Forgive me if this is a dumb question, but is there any to make 'SAFRCFileDlg' available in Windows 2000? Other than that, I now have what I want. Thanks again.
 
Steve, I'm under the impression, 'SAFRCFileDlg' is only
available in Windows XP.

PHV may be able to confirm, but the quick look-up I did,
seem to imply, that this was the case.

I don't think the FileDialog Object, has that same restriction. Just do remember to make refrence to
MS office Object Library.

Good luck, either way!
 
Possibly Roy,
...I hesitated to stipulate the fact,
that I've only tried it on XP, but the book I got it from,
gave me the impression, it wasn't a "new" feature.

I can't verify either way?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top