Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread How to locate records from a Query?
Mon, Jan 8 2007 2:13 PMPermanent Link

"Marcio Ehrlich"
Isn't there a way to Locate records from a Query using variants?

This one finds records:
   If QueryEmp.Locate('Emp',
                                    EditEmp.Text,
                                    [loCaseInsensitive, loPartialKey]) then

This doesn't find anything:
   If QueryEmp.Locate('Emp;Est',

VarArrayOf([EditEmp.Text,ComboBoxEst.Text]),
                                    [loCaseInsensitive,loPartialKey]) then

What is wrong? After all, QueryEmp IS ordered by "Emp, Est"...
Thanks,
Marcio

Mon, Jan 8 2007 3:02 PMPermanent Link

"Jose Eduardo Helminsky"
Marcio

>    If QueryEmp.Locate('Emp;Est',
>
> VarArrayOf([EditEmp.Text,ComboBoxEst.Text]),
>                                     [loCaseInsensitive,loPartialKey]) then

try assigning the text values of the components into some variables.

cEmp := EditEmp.Text;
cEst := ComboBoxEst.Text;
If
QueryEmp.Locate('Emp;Est',VarArrayof([cEmp,cEst]),[loCaseInsensitive,loPartialKey])
then

I don´t remeber why and where, but it has already happend with me.

Eduardo

Mon, Jan 8 2007 4:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Marcio,

<< This doesn't find anything:
   If QueryEmp.Locate('Emp;Est',
VarArrayOf([EditEmp.Text,ComboBoxEst.Text]),
                                    [loCaseInsensitive,loPartialKey]) then

What is wrong? After all, QueryEmp IS ordered by "Emp, Est"... >>

The ordering shouldn't matter.  It should always find what you're looking
for if it exists.  What values are you searching for, and what is present in
the table ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jan 8 2007 7:57 PMPermanent Link

"Marcio Ehrlich"
Nope, Ed, nada!
Let's see if Tim has a better idea.
M.


"Jose Eduardo Helminsky" <contato@hpro.com.br> escreveu:
> try assigning the text values of the components into some variables.
> cEmp := EditEmp.Text;
> cEst := ComboBoxEst.Text;
> If
>
QueryEmp.Locate('Emp;Est',VarArrayof([cEmp,cEst]),[loCaseInsensitive,loParti
alKey])
> then

Mon, Jan 8 2007 8:14 PMPermanent Link

"Marcio Ehrlich"
I'm looking for strings: the name of the company and its State.
Doing some more tests, I found out that the problem is with the
[,loPartialKey] option. It is not working.
When using a two-fields-search, only a total match gets me the record.
The "Locate" should read the contents of the respective TEdit and TComboBox
and search the query.
Nevertheless, if there is an "Elevate Software" in "NY", I will get nothing
if I just type "Elevate" at the TEdit, for instance.
Why is that so?
Marcio

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> escreveu:

> The ordering shouldn't matter.  It should always find what you're looking
> for if it exists.  What values are you searching for, and what is present
in
> the table ?

Tue, Jan 9 2007 7:49 AMPermanent Link

"Marcio Ehrlich"
Tim,
I have done some more testings and loPartialKey does not work either
accessing directly a TDbisamTable when searching two fields. So it's not
only a problem of locating records from a Query.
Unfortunatelly I do not have any Paradox table here to test what might be
going wrong.
Marcio

"Marcio Ehrlich" <marcioehrlich_at_ig.com.br> escreveu:

> Doing some more tests, I found out that the problem is with the
> [,loPartialKey] option. It is not working.

Tue, Jan 9 2007 8:38 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Marcio,

<< Nevertheless, if there is an "Elevate Software" in "NY", I will get
nothing if I just type "Elevate" at the TEdit, for instance. Why is that so?
>>

This is normal - loPartialKey only works on the last string field specified
for the locate.  You can't do a partial search on more than the last field
in a locate.  If you want to do that, then you'll need to use a filter
instead like this:

Company LIKE 'Elevate%' AND State='NY'

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jan 9 2007 9:58 AMPermanent Link

"Marcio Ehrlich"
Thank you very very much, Tim, but this seems to be a totally undocumented
behaviour.
Both Delphi and Dbisam Version 4 manuals say:
"If Options contains the loPartialKey setting, then Locate allows
partial-string matching on strings in KeyValues."
Plurals everywere. Smile
They never say "in the last KeyValue".
Anyway, thanks to your information, I corrected the problem by just
inverting the fields order:
 If QueryEmp.Locate('Est;Emp',
           VarArrayOf([ComboBoxEst.Text,EditEmp.Text]),
                                [loCaseInsensitive,loPartialKey]) then
  ...
Greetings from Rio,
Marcio


"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> escreveu:

> This is normal - loPartialKey only works on the last string field
specified
> for the locate.

Wed, Jan 10 2007 5:35 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Marcio,

<< Thank you very very much, Tim, but this seems to be a totally
undocumented behaviour. >>

I will make sure that the documentation is more explicit on this.  The
reason that it is done this way is to allow for index optimization of
partial-matches.  If partial matches were always done on all fields, then
they could never be optimized using an index.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image