Board index » delphi » locating a record with 2 conditions?

locating a record with 2 conditions?

i'm trying to display a dbtext field by two condtions between two different
tables.  it must be the company number and be the location number (which is
displayed on the main form).  as far as i know the function 'locate' can
only find 1 specific string in multiple fields within a table.  i need it to
find the company and location number.  here's what i have right now just to
find the company :

   editform1.table2.open;
   with editform1.table2 do
     b := Locate('company
key',editform1.editcompanykey.text,[loCaseInsensitive,loPartialKey]);

how would i find the record in table2 which has the company AND location
key?

please reply by e-mail and post,
darrin

 

Re:locating a record with 2 conditions?


dalin <da...@blackboard.cnchost.com> schreef in artikel
<645a17$...@examiner.concentric.net>...

Quote
> i'm trying to display a dbtext field by two condtions between two
different
> tables.  it must be the company number and be the location number (which
is
> displayed on the main form).  as far as i know the function 'locate' can
> only find 1 specific string in multiple fields within a table.  

Well, this is not really true. It is possible to select records using
multiple conditions, but of course only within the same table, by
separating the key-fields with semicolons and specifying the key-values
using an array. If I understand your question correctly, what you need to
do with table2 is the following:

        with editform1.table2 do
          b:=Locate('companykey; locationnumber', [editform1.editcompanykey.text,
{locationkeyvalue on
                      mainform}], IoCaseInsensitive, IoPartialKey]);

HTH,

        Niels.

Other Threads