We can configure our application to allow users to search for particular
records in the database. For demonstration purposes, we include a Find button to
allow users to query only employee names. At any time, the user can enter the
query in the Employee Name textbox and click on the Find button. Our application
then either displays the result, or displays a message if the name cannot be
found.
To search for records, we use the DbFindFirst method. When the find succeeds, we display the record. When the find fails,
we display a message. We also reset the current row to the first, since
failures cause the dynaset to be BOF, effectively making the current row invalid.
Our Find_Click() event procedure does the following:
Builds a find clause to find the record where the ENAME column matches the
entered string.
Executes the find using DbFindFirst.
Displays the record if found; if not found, displays a message and resets the
current row to first.