Board index » delphi » Table.Locate options for multiple field searches

Table.Locate options for multiple field searches

Hello fellow experts,

I am having some trouble setting the proper options in a table.locate
method. I have done locates
before with single field with no problem. However, I am now trying to
search a table based on
multiple fields and I am having trouble with the parameters.

I am using Delphi 2.

I have a table, let's call it table1, with fields : f1,f2,f3,f4,f5 (for
simplicity sake).

I am searching on f1 and f2, which are both A fields (string). I am looking
for the values
'Val1' and 'VAL2' in these two fields/columns in the table.

I do the following:

    table.locate('f1;f2',['VAL1','VAL2'],[])    I get the compile error
"Ordinal type required'

I try this

   table.locate('f1;f2','VAL1;VAL2',[])     which compiles fine but when
during runtime I get the error
                                                       "variant is not an
array"

I have tried other combination but to no avail.

Can any one help? I know I probably have the fundamentals wrong.

Thanks in advance,

Peter Cheung
Peter.Che...@ubc.ca

 

Re:Table.Locate options for multiple field searches


Hi! Peter.

Quote
>     table.locate('f1;f2',['VAL1','VAL2'],[])    I get the compile error
> "Ordinal type required'

> I try this

>    table.locate('f1;f2','VAL1;VAL2',[])     which compiles fine but when
> during runtime I get the error
>                                                        "variant is not an

array"

This works.

  table1.locate('f1;f2', varArrayOf([val1, val2]), []);

--------
Fujinaka Rika

Other Threads