Hi
I am using the common dialog control showopen to allow the user to select an access database file to connect to. My problem is that the drop down filename box lists several files on various drives, including one on a removable drive which is not mounted. My questions are :
1 where are these filenames coming from?
2 how do I list only the filtered files in the current dir?
The test code below shows this problem on winxp pro
Any help appreciated.
Andy
Option Explicit
Dim strOpenFlag, strOpenFilter, strFileSelected As String
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdOpen_Click()
strOpenFlag = cdlOFNHideReadOnly
strOpenFlag = strOpenFlag Or cdlOFNPathMustExist
strOpenFlag = strOpenFlag Or cdlOFNNoChangeDir
strOpenFilter = "Access Database (*.MDB) | *.mdb"
With Me.cdOpen1
.Flags = strOpenFlag
.InitDir = App.Path
.Filter = strOpenFilter
.ShowOpen
If Not .FileName = vbNullString Then
strFileSelected = .FileName
Else
strFileSelected = "No file selected"
End If
End With
MsgBox "File Selected is :" & vbCr & strFileSelected
End Sub
I am using the common dialog control showopen to allow the user to select an access database file to connect to. My problem is that the drop down filename box lists several files on various drives, including one on a removable drive which is not mounted. My questions are :
1 where are these filenames coming from?
2 how do I list only the filtered files in the current dir?
The test code below shows this problem on winxp pro
Any help appreciated.
Andy
Option Explicit
Dim strOpenFlag, strOpenFilter, strFileSelected As String
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdOpen_Click()
strOpenFlag = cdlOFNHideReadOnly
strOpenFlag = strOpenFlag Or cdlOFNPathMustExist
strOpenFlag = strOpenFlag Or cdlOFNNoChangeDir
strOpenFilter = "Access Database (*.MDB) | *.mdb"
With Me.cdOpen1
.Flags = strOpenFlag
.InitDir = App.Path
.Filter = strOpenFilter
.ShowOpen
If Not .FileName = vbNullString Then
strFileSelected = .FileName
Else
strFileSelected = "No file selected"
End If
End With
MsgBox "File Selected is :" & vbCr & strFileSelected
End Sub