Board index » delphi » Any idea why TQuery.Locate won't work

Any idea why TQuery.Locate won't work

I am using D3 and MSSQL6.5. After successfully posting a new record, I want
to return to the 'grid' positioned at the newly inserted record....common
sense..no?

Just before posting, I record the CustomID (a unique string value) then I
rebuild the query for the grid using an SQL statement like:   select field1,
field2 from MYFILE    (pretty common place)

Then the following line will fail even though I can SEE the record in the
updated grid and have verified that CurrentID does indeed contain the
correct value:

      if not (BrowseQuery.locate('CustomID', CurrentID, [loPartialKey]))
then....

Any idea why this won't work for a newly inserted record....(Yes, there is
an Identity field and a TEXT blob in the record/row, but I am NOT using that
as the locate parameter)

ARGHHH!!!!!!!

Charles
c...@sk.sympatico.ca

 

Re:Any idea why TQuery.Locate won't work


Hi Charles

Quote
>       if not (BrowseQuery.locate('CustomID', CurrentID, [loPartialKey]))
> then....

If CustomID is an integer field then do not use the loPartialKey, eg;
  if not (BrowseQuery.locate('CustomID', CurrentID, [])) then..

Hope this helps.

Cheers
John Hair
Designer Systems Ltd

Re:Any idea why TQuery.Locate won't work


For the sake of others:
I found the reason TQuery.Locate did not find data I KNEW was there:
Somewhere between the Posting and the rebuild of the Query, the LENGTH of
the search key was changing (I don't know why, yet)...so using the
TrimRight() function for the locate did the job.
CJY

Quote
Charles Yeo wrote in message <6f4f4n$f...@dragon.sk.sympatico.ca>...
>I am using D3 and MSSQL6.5. After successfully posting a new record, I want
>to return to the 'grid' positioned at the newly inserted record....common
>sense..no?

>Just before posting, I record the CustomID (a unique string value) then I
>rebuild the query for the grid using an SQL statement like:   select
field1,
>field2 from MYFILE    (pretty common place)

>Then the following line will fail even though I can SEE the record in the
>updated grid and have verified that CurrentID does indeed contain the
>correct value:

>      if not (BrowseQuery.locate('CustomID', CurrentID, [loPartialKey]))
>then....

>Any idea why this won't work for a newly inserted record....(Yes, there is
>an Identity field and a TEXT blob in the record/row, but I am NOT using
that
>as the locate parameter)

>ARGHHH!!!!!!!

>Charles
>c...@sk.sympatico.ca

Other Threads