problem vieing .mdb files with openfiledialog

M

Mike

I need help understanding why the following code is not working correctly.
When run, I can open .mdb files by changing the filter option to "All Files
(*.*)" but while "Access Database (mdb.*)" is selected no db files are
listed in the OpenFileDialog box....
-------------------------------------
Private Sub btnDatabase_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDatabase.Click
Dim objOpenFileDialog As New OpenFileDialog

With objOpenFileDialog
.Filter = "Access Database (*.mdb)|*.mdb | All files (*.*)|*.*"
.FilterIndex = 1
.InitialDirectory = "C:\"
.Title = "Open Access Database"
End With

If objOpenFileDialog.ShowDialog = DialogResult.OK Then
txtDatabase.Text = objOpenFileDialog.FileName
End If
End Sub
 
T

Thorsten Doerfler

Mike said:
I need help understanding why the following code is not working correctly.
When run, I can open .mdb files by changing the filter option to "All Files
(*.*)" but while "Access Database (mdb.*)" is selected no db files are
listed in the OpenFileDialog box....
-------------------------------------
Private Sub btnDatabase_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDatabase.Click
Dim objOpenFileDialog As New OpenFileDialog

With objOpenFileDialog
.Filter = "Access Database (*.mdb)|*.mdb | All files (*.*)|*.*"
.FilterIndex = 1
.InitialDirectory = "C:\"
.Title = "Open Access Database"
End With

If objOpenFileDialog.ShowDialog = DialogResult.OK Then
txtDatabase.Text = objOpenFileDialog.FileName
End If
End Sub

Not tried, but remove the spaces between the filter entries:
..Filter = "Access Database (*.mdb)|*.mdb|All files (*.*)|*.*"

Thorsten Doerfler
 
A

Angel J. Hernández M.

Hi there... You shouldn't leave spaces between pipe or separator (Chr 124)
and pipe (Check the second separator). You wrote something like
.Filter = "Access Database (*.mdb)|*.mdb | All files (*.*)|*.*"

instead of

.Filter = "Access Database (*.mdb)|*.mdb| All files (*.*)|*.*"

Regards,
 
M

Mike

Thanks. that was it.
-m
Thorsten Doerfler said:
Not tried, but remove the spaces between the filter entries:
.Filter = "Access Database (*.mdb)|*.mdb|All files (*.*)|*.*"

Thorsten Doerfler
 
M

Mike

Thanks,
that was it.

-m

Angel J. Hernández M. said:
Hi there... You shouldn't leave spaces between pipe or separator (Chr 124)
and pipe (Check the second separator). You wrote something like
.Filter = "Access Database (*.mdb)|*.mdb | All files (*.*)|*.*"

instead of

.Filter = "Access Database (*.mdb)|*.mdb| All files (*.*)|*.*"

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top