Hi J,
What version of Access are you using? What file type are you trying to open?
Invoking a file picker dialog has been greatly simplified in Access 2002 which includes a FileDialog property of the Application object. If you're using a version of Access prior to 2002, you'll need to use the Common Dialog ActiveX control that ships with the MOD edition of Office, an API call, or a custom class, none of which are trivial to implement.
Here's a sample of how you can use the FileDialog property in Access XP to select all files, or filter for just .mdb/.mde or .xls files from your current db:
Private Sub cmdFilePicker_Click()
Dim varItem As Variant
Dim strOut As String
Const conFileDialogFilePicker As Long = 3
With _
Application.FileDialog(conFileDialogFilePicker)
.ButtonName = "Select"
.Title = "Choose your files"
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "All Files", "*.*", 1
.Filters.Add "Access databases", "*.mdb; *.mde", 2
.Filters.Add "Excel Files", "*.xls", 3
.FilterIndex = 2
.Show
If .SelectedItems.Count > 0 Then
For Each varItem In .SelectedItems
strOut = strOut & varItem & vbCrLf
Next varItem
End If
End With
Me.txtSelectedFiles = strOut
End Sub
HTH,
Bob
|