Board index » delphi » Searching compound Index

Searching compound Index

Hi Everyone,

I am having problems learning how to search a Paradox table
based on a secondary index on a lastname and firstname.

I have formed a secondary index on lastname & firstname (NAME)
using the database destop.

My code for a click event is as follows,

The code does not find the record even when I put in
a name with padded spaces to fill the field size.

Can anyone suggest what I am doing or not doing.  Thanks

procedure TForm8.Button1Click(Sender: TObject);
var
slf : string;
begin
//edit1.text:='Fraser         ';
//edit2.text:='Malcolm        ';
slf:=edit1.text+edit2.text;
Datamodule2.Table1.Indexname:='NAME';
if not Datamodule2.Table1.FindKey([slf]) then
    MessageBox(Handle,'Record not found','Message',MB_OK);

form4.close;
end;

 

Re:Searching compound Index


Hi,

Have you tried giving the filed values as an array;

Or, try using locate and give the filed values as a variant array

You can give multiple fields as the key ffield and will use index if one
exists.

another way is to use setkey, GoToKey methods

hope this helps

Salim

Quote
Malcolm Fraser wrote in message <7duhgl$d4...@forums.borland.com>...
>Hi Everyone,

>I am having problems learning how to search a Paradox table
>based on a secondary index on a lastname and firstname.

>I have formed a secondary index on lastname & firstname (NAME)
>using the database destop.

>My code for a click event is as follows,

>The code does not find the record even when I put in
>a name with padded spaces to fill the field size.

>Can anyone suggest what I am doing or not doing.  Thanks

>procedure TForm8.Button1Click(Sender: TObject);
>var
>slf : string;
>begin
>//edit1.text:='Fraser         ';
>//edit2.text:='Malcolm        ';
>slf:=edit1.text+edit2.text;
>Datamodule2.Table1.Indexname:='NAME';
>if not Datamodule2.Table1.FindKey([slf]) then
>    MessageBox(Handle,'Record not found','Message',MB_OK);

>form4.close;
>end;

Re:Searching compound Index


Hi Everyone,

I have figured out what I was doing wrong and my code with a couple
of small modifications works fine.

My errors were as usual rather silly and I apologize for wasting
anyone's time!

Thanks

Malcolm Fraser
IMF Consultants

Other Threads