search in DBGRID

here is the question :->
say I have retrieved 100s of rows of data in dbgrid eg names of employees,now I want to find eg John smith , one way to do this is to force the user to look through rows and find it OR we may give them the find option as in MS word, but how can I put the cursor to that particular column matching the search result and make that column highlighted?

any suggestions?
maboAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MikeP090797Connect With a Mentor Commented:
You can do that using the Like operator:
Data.RecordSet.FindFirst "LastName Like Sm*"

Will find the record that it's LastName begins with sm.
Take a closer look at the Like operator in VB's help
0
 
MikeP090797Commented:
With only 100 rows you can use Data.recordset.findfirst. Then put the cursor to a column using the col property
0
 
maboAuthor Commented:
will this allow wild card search as well?
eg if someone is searching for Smith then SmithField should be
highlighted as well.
any comments?......


0
 
MikeP090797Commented:
You can use any pattern that is valid in recordset's search. When to record is found, no matter what the criteria is, the dbgrid's current record set t the record that was found. Then you just need to put the selection to the column you were searching using the .cols proprty. If you post a specific situation, i will give a sample code.
0
 
maboAuthor Commented:
ok, just have a look at the VB5 find facility, it has wild card
match, exact match etc, I am looking for something similar to that.
0
All Courses

From novice to tech pro — start learning today.