Board index » delphi » Locate, LocateNext - help required please

Locate, LocateNext - help required please

Delphi 5.01 Pro
IBX 4.3
IB 6

I'm trying to implement a simple locate, locate next procedure for a grid.

I can get the app to locate the first record using :

If Not(SQLDataSet.LocateNext('DISPLAYAS',edSearchText.Text ,
[loCaseInsensitive, loPartialKey])) Then ShowMessage ('No more matches.');

However when I click the button to look for other matches, it brings up the
same record again and does not move on even when I use FindNext after the
above code.

Could anyone help me by posting a code snippet that successfully implements
the procedure or point me in the direction of where to look. I've been
puzzling over this for a couple of days.

Many Thanks

Nick

 

Re:Locate, LocateNext - help required please


Hi:

   If the table is indexed on the field you are searching, then they will be in order
by that field and the next is the next record??

                                                            Best regards

Re:Locate, LocateNext - help required please


Thanks for taking the time to reply. The DataSet is a combination of two
tables combined - one full of addresses and one full of people who live in
those addesses. The field I'm searching 'DISPLAYAS'  is in the people table
and has an index for it which shows the data in A-Z order by name.

I can see the records in the grid in the correct A-Z order. However once
I've found the first instance of a name using Locate/LocateNext it will not
move onto the next record eg.

Smith, Bill     <-------stops at the first and will not move to the next
Smith, John
Smith, Lisa

If you have successfully used Locate/LocateNext could you provide an example
of the code and or explain how you went about it.

Many thanks in advance.

Nick

"Robert F. Tulloch" <tult...@ibm.net> wrote in message
news:3A69B437.8B093E36@ibm.net...

Quote
> Hi:

>    If the table is indexed on the field you are searching, then they will
be in order
> by that field and the next is the next record??

>                                                             Best regards

Re:Locate, LocateNext - help required please


Hi:

Quote
> Smith, Bill     <-------stops at the first and will not move to the next
> Smith, John
> Smith, Lisa

  If this is what you have, why do you need LocateNext to get to Smith, John?

  Very confusing. Either it is the next record in a grid or the next record to scroll
to with a navigator.

  Find next would be useful if you were looking for street names in a table indexed on
LastName asc, FirstName asc for instance.

                                                     Best regards

Re:Locate, LocateNext - help required please


I was using Smith as a test to make sure my code worked.

There are other fields such as CompanyName where partial seaches would be
used for example when the user can only remember the second word in the
CompanyName.

However I'm open to suggestions, how would you use Find Next?

Cheers

Nick

"Robert F. Tulloch" <tult...@ibm.net> wrote in message
news:3A6A305A.8A5904F3@ibm.net...

Quote
> Hi:

> > Smith, Bill     <-------stops at the first and will not move to the next
> > Smith, John
> > Smith, Lisa

>   If this is what you have, why do you need LocateNext to get to Smith,
John?

>   Very confusing. Either it is the next record in a grid or the next
record to scroll
> to with a navigator.

>   Find next would be useful if you were looking for street names in a
table indexed on
> LastName asc, FirstName asc for instance.

>                                                      Best regards

Re:Locate, LocateNext - help required please


I was using Smith as a test to make sure my code worked.

There are other fields such as CompanyName where partial seaches would be
used for example when the user can only remember the second word in the
CompanyName.

However I'm open to suggestions, how would you use Find Next?

Cheers

Nick

"Robert F. Tulloch" <tult...@ibm.net> wrote in message
news:3A6A305A.8A5904F3@ibm.net...

Quote
> Hi:

> > Smith, Bill     <-------stops at the first and will not move to the next
> > Smith, John
> > Smith, Lisa

>   If this is what you have, why do you need LocateNext to get to Smith,
John?

>   Very confusing. Either it is the next record in a grid or the next
record to scroll
> to with a navigator.

>   Find next would be useful if you were looking for street names in a
table indexed on
> LastName asc, FirstName asc for instance.

>                                                      Best regards

Re:Locate, LocateNext - help required please


Hi:

  What if the word they can remember is Company? Just joking. I worked in Indonesia
and every store name was prefixed by Toko so the standard joke was in looking up
stores you just looked in phone book under stores and every one was sorted on the word
Toko. Of course then you had to search through to find what you were really looking
for. Same thing for companies. Each had Pt. in front of the name.

  My understanding of partial key:

  Joes Fast Diner is the key.

  Locate Fast will not find Joes Fast.

  Someone can correct me if I am wrong. Your looking for a word "contained" somewhere
in the field.

Re:Locate, LocateNext - help required please


That's right maybe the user could be looking for in the company name field
but only remember part of the company name which is why I opted for

If Not(SQLDataSet.LocateNext('DISPLAYAS',edSearchText.Text ,
[loCaseInsensitive, loPartialKey])) Then ShowMessage ('No more matches.');

because of the loPartialKey would pick up 'Joe Plumbing Sevices' if the user
searched under 'Plumbing', and I was hoping it ould pick up any other
company with the word 'Plumbing' in it.

At the end of the day this feature is not crucial, it's just handy; I use to
use MS Access and to quickly skip through a table of 2000 records with a
partial search was I found very handy.

Perhaps my understanding of Locate/LocateNext is wrong and I'm not using it
correctly. I didn't have an example so like I said I could incorrect in my
assumption.

If someone could set me straight I would be very grateful.

Thanks again

Nick

"Robert F. Tulloch" <tult...@ibm.net> wrote in message
news:3A6B2D7D.7A87098F@ibm.net...

Quote
> Hi:

>   What if the word they can remember is Company? Just joking. I worked in
Indonesia
> and every store name was prefixed by Toko so the standard joke was in
looking up
> stores you just looked in phone book under stores and every one was sorted
on the word
> Toko. Of course then you had to search through to find what you were
really looking
> for. Same thing for companies. Each had Pt. in front of the name.

>   My understanding of partial key:

>   Joes Fast Diner is the key.

>   Locate Fast will not find Joes Fast.

>   Someone can correct me if I am wrong. Your looking for a word

"contained" somewhere

- Show quoted text -

Quote
> in the field.

Re:Locate, LocateNext - help required please


Quote
Nick Barkworth wrote:

> I can get the app to locate the first record using :

> If Not(SQLDataSet.LocateNext('DISPLAYAS',edSearchText.Text ,
> [loCaseInsensitive, loPartialKey])) Then ShowMessage ('No more matches.');

> However when I click the button to look for other matches, it brings up the
> same record again and does not move on even when I use FindNext after the
> above code.

        FindNext will not do what you want.  Use LocateNext again.

        HTH,

        -Craig

--
Craig Stuntz               Vertex Systems Corporation
Senior Developer           http://www.vertexsoftware.com

Delphi/InterBase weblog:   http://delphi.weblogs.com

Re:Locate, LocateNext - help required please


The code attached to the button is:

If Not(SQLDataSet.LocateNext('DISPLAYAS',edSearchText.Text ,
[loCaseInsensitive, loPartialKey])) Then ShowMessage ('No more matches.');

I only used FindNext to see if I could move things along, after the above
would not work.
When you say use LocateNext again, do you mean I just have to re-execute the
above code ie press the button again, as this is what is giving me trouble.

If you have successfully implemented a Locate/LocateNext procedure could you
let me have a look at your code.

Many thanks for taking the time to help.

Nick

Quote
----- Original Message -----
From: "Craig Stuntz" <cstuntz@no_spam.vertexsoftware.com>

Newsgroups: borland.public.delphi.database.interbaseexpress
Sent: 22 January 2001 14:35
Subject: Re: Locate, LocateNext - help required please

> Nick Barkworth wrote:

> > I can get the app to locate the first record using :

> > If Not(SQLDataSet.LocateNext('DISPLAYAS',edSearchText.Text ,
> > [loCaseInsensitive, loPartialKey])) Then ShowMessage ('No more
matches.');

> > However when I click the button to look for other matches, it brings up
the
> > same record again and does not move on even when I use FindNext after
the
> > above code.

> FindNext will not do what you want.  Use LocateNext again.

> HTH,

> -Craig

> --
> Craig Stuntz    Vertex Systems Corporation
> Senior Developer    http://www.vertexsoftware.com

> Delphi/InterBase weblog:   http://delphi.weblogs.com

Re:Locate, LocateNext - help required please


Quote
Nick Barkworth wrote:

> When you say use LocateNext again, do you mean I just have to re-execute the
> above code ie press the button again, as this is what is giving me trouble.

        I think I understand your problem now.

        LocateNext starts looking at the *current record.*  So if you're
already on a matching record, you need to run Next first.

        HTH,

        -Craig

--
Craig Stuntz               Vertex Systems Corporation
Senior Developer           http://www.vertexsoftware.com

Delphi/InterBase weblog:   http://delphi.weblogs.com

Re:Locate, LocateNext - help required please


Quote
Craig Stuntz wrote:

> Nick Barkworth wrote:

> > When you say use LocateNext again, do you mean I just have to re-execute the
> > above code ie press the button again, as this is what is giving me trouble.

>         I think I understand your problem now.

>         LocateNext starts looking at the *current record.*  So if you're
> already on a matching record, you need to run Next first.

I fixed this for the next update.

Quote
>         HTH,

>         -Craig

> --
> Craig Stuntz               Vertex Systems Corporation
> Senior Developer           http://www.vertexsoftware.com

> Delphi/InterBase weblog:   http://delphi.weblogs.com

--
Jeff Overcash (TeamB)   | Talk about failure
(Please do not email    | To fall is not to fail
 me directly unless     | Failure isn't about falling down
 asked.  Thank You)     | Failure is staying down (Marillion)

Re:Locate, LocateNext - help required please


Thanks Craig

I used 'Next' as you suggested and it did the trick.

Thanks again, as you can imagine these sort of little problems can be the
most frustrating - hope your code remains bug free !

Nick

Quote
"Craig Stuntz" <cstuntz@no_spam.vertexsoftware.com> wrote in message

news:3A6C68BB.F3A6AF61@no_spam.vertexsoftware.com...
Quote

> Nick Barkworth wrote:

> > When you say use LocateNext again, do you mean I just have to re-execute
the
> > above code ie press the button again, as this is what is giving me
trouble.

> I think I understand your problem now.

> LocateNext starts looking at the *current record.*  So if you're
> already on a matching record, you need to run Next first.

> HTH,

> -Craig

> --
> Craig Stuntz    Vertex Systems Corporation
> Senior Developer    http://www.vertexsoftware.com

> Delphi/InterBase weblog:   http://delphi.weblogs.com

Re:Locate, LocateNext - help required please


Quote
Nick Barkworth wrote:

> I used 'Next' as you suggested and it did the trick.

        Just a warning: Based on what Jeff just wrote, you may need to undo
this "fix" after the next IBX update.

        I actually prefer the way it works now, but I can live with it either
way.

        -Craig

--
Craig Stuntz               Vertex Systems Corporation
Senior Developer           http://www.vertexsoftware.com

Delphi/InterBase weblog:   http://delphi.weblogs.com

Go to page: [1] [2]

Other Threads