Let's assume that your DBF table has two fields. An integer key field called KEY and a character field called NAME.
The sample code that follows will allow the user to enter a number in an edit field and then click on a button to reveal the name associated with the key. I'm sure your application will be more complex but the ideas should apply.
Put the following components on your form:
TTable - name it mensa
TDataSource - name it sauce
TDBEdit - name it dbeName
TEdit - name it edKey
TButton - name it btnFind
Ensure that there is a database alias set up for your table (use BDEAdmin.EXE).
Set the Text property of edKey to blank
Set the DatabaseName property of mensa to the alias name Set the TableName property of mensa to the actual .DBF name of the table
Set the Active property of mensa to True
Set the DataSet property of sauce to mensa
Set the DataSource property of dbeName to sauce
Set the DataField property of dbeName to NAME
At this point the actual NAME data from the first record of the table should be visible in dbeName.
Now double click on the button. An edit window should appear into which you should add code so it looks like this:
Code:
procedure TForm1.btnFindClick(Sender: TObject);
begin
if not mensa.FindKey ( [ StrToIntDef ( edKey.text, Low(integer) ) ] ) then
ShowMessage ( 'No record for this key' );
end;
If you are not sure what things like FindKey and StrToIntDef to check out the Delphi Help by pressing F1.
Now (save and) run (F9) the program.
There's quite a lot to learn when you first use Delphi. But it is a really neat, powerful development tool and well worth the effort. There are a lot of Delphi enthusiasts in this forum who will be pleased to help you but remember to have a go first and demonstrate that you've tried. Ideally show a bit of code and say "I'm trying to get this effect with this bit of code but it fails in this way" rather than simply "Show me how to do this".
Andrew