I prefer to use a Windows API call rather than the control because when I distribute the application to various users, if they don't have the correct version of the control the application blows up.
Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
'Browsing for directory.
Private Const BIF_RETURNONLYFSDIRS = &H1 'For finding a folder to
'start document searching
Private Const BIF_DONTGOBELOWDOMAIN = &H2 'For starting the Find
'Computer
Private Const BIF_STATUSTEXT = &H4
Private Const BIF_RETURNFSANCESTORS = &H8
Private Const BIF_BROWSEFORCOMPUTER = &H1000 'Browsing for Computers.
Private Const BIF_BROWSEFORPRINTER = &H2000 'Browsing for Printers
Private Const BIF_BROWSEINCLUDEFILES = &H4000 'Browsing for Everything
Private Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "KERNEL32" Alias "lstrcatA" (ByVal _
lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As _
BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList _
As Long, ByVal lpBuffer As String) As Long
Dim OpenFile As OPENFILENAME
Dim lngReturn As Long
Dim strFilter As String
Dim strFilename As String
Me.cboSelector = Null
With OpenFile
.lStructSize = Len(OpenFile)
.hwndOwner = Me.hWnd
.hInstance = Application.hWndAccessApp
strFilter = "DMATS data (Data*.mdb;Data*.mde)" _
& Chr(0) & "data*.mdb" _
& Chr(0) & "data*.mde" & Chr(0) & Chr(0)
.lpstrFile = String(257, 0)
.lpstrFilter = strFilter
.nFilterIndex = 1
.nMaxFile = Len(.lpstrFile) - 1
.lpstrTitle = "Locate DMATS data file"
'.Flags = cdlOFNFileMustExist
lngReturn = GetOpenFileName(OpenFile)
If lngReturn = 0 Then
GoTo Exit_Proc
End If
'.Flags = cdlOFNFileMustExist
If Len(.lpstrFile) > 0 Then
strFilename = Mid$(OpenFile.lpstrFile, 1, _
InStr(1, OpenFile.lpstrFile, Chr(0)) - 1)
Me.cboSelector = LCase(strFilename)
Me.cmdFinish.Enabled = True
FPath_Filename = LCase(strFilename)
End If
End With
Steve King Growth follows a healthy professional curiosity