
Implementing "find" in dbgrid
I will make a few assumptions here:
your dbGrid is connected to a Data Control (this is an object you will have
on your form) The Data control has a recordset and you can use FindFirst as
you have rightly pointed out.
So get the name of the data control ... look up its properties and say...
<data control name>.Recordset.FindFirst "<string you want to find>"
you can then use FindNext to get the next occurence of your string.
The help files should explain it all.
]> >How do you give the user the ability to search a table on the current
Quote:
> >field in a dbgrid? In other words: I have a simple form with just a
> >dbgrid that connects to a single table. I want the user to be able to
> >position the cursor in any field in the grid, then click on a command
> >button that prompts for a value and searches the table on the current
> >field for that value. I would have thought there would be a built-in
> >control for this.
> >I started writing a command button from scratch to do this. My current
> >problem is that I can't find out how to get the name of the current
> >field. How do you get the name of the current field in a dbgrid? I
> >need the field name to use as an argument to the findfirst method.
> >I've spent well over an hour reading the manuals, reading the online
> >help, and testing guesses, just to find out how to get the name of the
> >current field. I feel I have not caught on yet to using the VB manuals
> >and online help, because the connections often seem convoluted. For
> >instance, I discovered by chance that you can use the findfirst method
> >with a data control object by typing data1.recordset.findfirst, but
> >there is no explict indication in the description of "data control"
> >that the construction "data1.recordset" is valid. I suspect there
> >exists a crucial threshhold of familiarity with VB that I need to
> >cross before I can start finding the information I need in a
> >reasonable amount of time.
> >Christopher Schmidt
> >Tucson, Arizona, USA
> Bruce Wojak V Builder Software Inc
> 708 923 9999 fax 708 923 0207
> Web site www.vbuilder.com