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 Chris Miller 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 dialog box 1

Status
Not open for further replies.

dfwelch

Programmer
Dec 5, 2003
51
US
It cannot be as difficult as I am seeing to get a Browse for File to open dialog box to pop up from an Access form! I just want a button next to a text box control. The text box will accept the location of the file, as in "C:\SomeFolder\thisfile.xls", where an Excel input file is located. I would also like to have a Browse for file button next to the box that will open a dialog box so the user can browse to the file and have the path filled into the text box.

The only solutions I seen take like six different functions! Is it really that complicated?!!?
 
Yes. You have to make API calls to Windows to do it. The next version of Access will probably use the .Net framework, and this problem will come to the end. Until that day comes, we can only type, type, type.
 
Actually there is a very easy way to do so...

Simply use the file dialog class:
I don't really feel like explaining it all, but its actually REALLY easy to use...here is a code snippit...


Private Sub cmdSelectInput_Click()
Dim varItem As Variant

With Application.FileDialog(msoFileDialogFilePicker)
'setup File Dialog
.AllowMultiSelect = True
.ButtonName = "Select"
.InitialView = msoFileDialogViewList
.Title = "Select Input Files"

'add filter for excel
With .Filters
.Clear
.Add "Excel Spreadsheets", "*.xls"
End With
.FilterIndex = 1

'display file dialog box
If .Show Then
'get selected files
For Each varItem In .SelectedItems
If Not (AddListItem(lstInput, False, varItem)) Then
ErrorMsgBox ("The input file (" & varItem & ") is already selected. Try Again.")
End If
Next varItem
End If
If lstInput.ListCount > 0 Then
cmdRun.Enabled = True
End If
End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top