FILTER/wildcard search a Datagridview (access database)
HI there
this is a visual basic 2008 project
I have made a program that uses an access database file (with a query) displayed on a datagridview. the access database has a column named 'Real Name'
now I have made it so that you enter in whatever the real name is that you want to search, then you click a button, and it uses the FIND function to bring you to the specific entry that you are looking for.
the search is case insensitive, but only supports an exact match.
the code is here:
notes:
dbbrowser.vb is the form that contains the datagrid view
EPCMemberQueryBindingSource1 is my access database query.
Code:
'if the texbox is blank, show an error message
If txtRealname.Text = "" Then
MessageBox.Show("Please enter a value!!", "doh!")
Else
' close any current instances of the dbbrowser form, and then open a new one
DBBrowser.Close()
DBBrowser.Show()
Dim itemFound As Integer = DBBrowser.EPCMemberQueryBindingSource1.Find("Real Name", txtRealname.Text)
DBBrowser.EPCMemberQueryBindingSource1.Position = itemFound
End If
'set the textbox text to blank
txtRealname.Text = ""
now I want to know two things.
when you run my code, it only works for a case insensitive, EXACT search. the problem is that I want it to work with wildcards, so that you can enter in
mar
and then it finds the entry that has the real name 'martin'
so how do I do that?
secondly, the next problem I want to get around is that
if you search
mar
and my form contains two entries:
Martin Bloggs
Martin white
my find function will only bring you to one of the martin entries. added to this, you can see the whole database in the datagridview.
because of this, I would much prefer to have a FILTER function.
If I can make it filter, I want it so that
you type in 'mar'
and the datagridview shows only two rows, one is martin bloggs and one is martin white, and it hides all other database entries.
if one of you kind and helpful souls could give me a clear, easy to understand answer to my questions, I would be most grateful.
You must give the answer in a clear way because I won't understand!
I am english etc so I can understand english, but what I mean is because I am quite new to Visual basic, I may not understand what you mean or what to do.
Thank you very much
Corey
ps
if it helps you to give clear instructions, here is my DBBrowser.vb form code:
Code:
Public Class DBBrowser
Private Sub DBBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'EPCDatabaseDataSet1.EPCMemberQuery' table. You can move, or remove it, as needed.
Me.EPCMemberQueryTableAdapter1.Fill(Me.EPCDatabaseDataSet1.EPCMemberQuery)
'TODO: This line of code loads data into the 'EPCDatabaseDataSet.EPCMemberQuery' table. You can move, or remove it, as needed.
Me.EPCMemberQueryTableAdapter.Fill(Me.EPCDatabaseDataSet.EPCMemberQuery)
End Sub
End Class
Thanks again.