Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Database using editbox and button

Status
Not open for further replies.

Venturi

Programmer
May 22, 2001
14
NL
Hi,

I've done this thing before but i have forgotten how :).Here is the problem. On a form I've got DBedit items. they get userinformation from a table. I also have a Editbox and a 'search'-button. I want to enter a number in de Editbox and when I press the button I want it to search the table for the corresponding record. When he finds it he has to display all the user information in the DBeditboxes.

THNX in advange.
 
if Table1.Locate('Table FieldName',Edit1.Text,[]) then
begin

{The table will have jumped to the record entered if it has been found}

end;

If using a tables internal record numbers you can use the RecNo command to return the current table record number.
 
THNX EricDraven!

this is even an easier way than i have done it the last time.

 
My favourite with only an editbox:

procedure edtSearchChange( Sender: TObject);
begin
if (edtSearch.Text <>'') then
try
table1.FindNearest(edtSearch.Text]);
except;
on EDatabaseError do;
on EConverterror do;
end;
end;

This procedure compares all fields, and position the cursor at the closest match. S. van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top