Board index » delphi » Locate next or find next?

Locate next or find next?

I am using a parradox 7 database and I need to use a search to find
various entrys.

I am currently using locate but I cant figure out how to "find the
next entry" any help would be apprieciated any code samples or
components would also be very appreciated.

TIA

Ian
ian.bl...@zetnet.co.uk

 

Re:Locate next or find next?


On Fri, 1 May 1998 20:24:57 +0100, Ian Black <ian.bl...@zetnet.co.uk>
wrote:

Quote
>I am using a parradox 7 database and I need to use a search to find
>various entrys.

>I am currently using locate but I cant figure out how to "find the
>next entry" any help would be apprieciated any code samples or
>components would also be very appreciated.

I've asked that very question some time ago, and my research has shown
that there isn't one. You'll have to do it the hard way (just like the
rest of us chickens) using TTable.EOF and TTable.Next.

For example:

Find First:

Table.Locate('Name','Santa',[loPartialKey,loCaseInsensitive]);

Find Next:

Found := False;
while not (Found or Table.EOF) do
begin
  Table.Next;
  S := UpperCase(TableName.AsString);
  if S = UpperCase('SANTA') then
    Found := True
end;

Something like that. Good luck.

Re:Locate next or find next?


In article <354ac7e2.38795...@news.mia.bellsouth.net>#1/1,

Quote
  Mauri...@bellsouth.net wrote:

> On Fri, 1 May 1998 20:24:57 +0100, Ian Black <ian.bl...@zetnet.co.uk>
> wrote:

> >I am using a parradox 7 database and I need to use a search to find
> >various entrys.

> >I am currently using locate but I cant figure out how to "find the
> >next entry" any help would be apprieciated any code samples or
> >components would also be very appreciated.

> I've asked that very question some time ago, and my research has shown
> that there isn't one. You'll have to do it the hard way (just like the
> rest of us chickens) using TTable.EOF and TTable.Next.

> For example:

> Find First:

> Table.Locate('Name','Santa',[loPartialKey,loCaseInsensitive]);

> Find Next:

> Found := False;
> while not (Found or Table.EOF) do
> begin
>   Table.Next;
>   S := UpperCase(TableName.AsString);
>   if S = UpperCase('SANTA') then
>     Found := True
> end;

> Something like that. Good luck.

       Did you try TTable.FindNext? Or setting a filter on the
table, then using a Next loop?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Re:Locate next or find next?


Quote
On Sat, 02 May 1998 11:53:37 -0600, ullr...@math.okstate.edu wrote:
>> >I am using a parradox 7 database and I need to use a search to find
>> >various entrys.

>> >I am currently using locate but I cant figure out how to "find the
>> >next entry" any help would be apprieciated any code samples or
>> >components would also be very appreciated.

>> I've asked that very question some time ago, and my research has shown
>> that there isn't one. You'll have to do it the hard way (just like the
>> rest of us chickens) using TTable.EOF and TTable.Next.

>       Did you try TTable.FindNext? Or setting a filter on the
>table, then using a Next loop?

Hm. Perhaps there is something I don't understand, and perhaps you can
explain it to me. (Pretty please?)

Say I have a TDBGrid connected to a TTable via a TDataSource. The
TTable contains (and the TDBGrid displays), say, customer records. The
user has already instructed the application to only display customers
who have an account balance in excess of a certain amount, which means
that the TTable is already filtered.

Now, the user wishes to locate two customers called Smith, without
changing the TDBGrid display (only changing the active record). He
hits Ctrl+F. The application pops up a dialog box, and the user enters
"smith" and clicks a "Name" checkbox. When the user clicks "Find Now",
the application uses TTable.Locate to find the first occurrence of the
name "Smith".

Satisfied, the user hits F3 to cause the application to find the next
occurrence of "Smith". How should the application proceed?

Re:Locate next or find next?


On Sat, 02 May 1998 18:17:35 GMT, Mauri...@bellsouth.net ({*word*104}cat)
wrote:

Quote
>Hm. Perhaps there is something I don't understand, and perhaps you can
>explain it to me. (Pretty please?)

>Say I have a TDBGrid connected to a TTable via a TDataSource. The
>TTable contains (and the TDBGrid displays), say, customer records. The
>user has already instructed the application to only display customers
>who have an account balance in excess of a certain amount, which means
>that the TTable is already filtered.

>Now, the user wishes to locate two customers called Smith, without
>changing the TDBGrid display (only changing the active record). He
>hits Ctrl+F. The application pops up a dialog box, and the user enters
>"smith" and clicks a "Name" checkbox. When the user clicks "Find Now",
>the application uses TTable.Locate to find the first occurrence of the
>name "Smith".

>Satisfied, the user hits F3 to cause the application to find the next
>occurrence of "Smith". How should the application proceed?

P.S. I really don't see why TDataSet.FindNext should (ever) be useful.
According to the documentation, FindNext will attempt to find the next
record in a filtered dataset - so would Next. The only advantage (as
far as I can see) is that FindNext saves one from having to check EOF.

Re:Locate next or find next?


In article <354b6389.37058...@news.mia.bellsouth.net>#1/1,

Quote
  Mauri...@bellsouth.net wrote:

          When I asked whether you'd tried FindNext that was
actually a question. The docs say something about TDataSet.FindNext
being implemented in TTable, but offhand I don't see where that
happens.
          I don't see quite why you can't just use a filter
and say Next. You say the table's already filtered - you
could change the filter. You don't want to change the view
in the grid - why not? And/or why not just use a different
TTable.

        About the database stuff I'm just a beginner. I
woundered exactly how to do exactly what you're wondering
about, never did get it quite figured out, decided to
worry about it when I had to. BUT I can tell you it hasn't
come up the way I thought it would:

        Maybe I'm keeping track of whether various students
have passed various exams yet. I'd start by worrying about
how to do what you want: I've already found the student,
don't want to change that while I look for the next exam.
But it's turned out that anytime this has come up it's
actually been _one_ table I didn't want to disturb, and
a _different_ table that I wanted to filter and Next.
Like I have students.db including one record for each student,
giving each student a number, etc, and exams.db,
a many-to-many thing with one record for each exam passed
by each student. I find the student I want in students.db -
now I leave students.db alone, I use that student number
to filter exams.db, and then I get the information on
what exams this student has passed with a Next loop
in exams.db.

        I don't see why you can't do something like that.
I don't know whether it's the official right thing to
do but it works for me.

David C. Ullrich

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Other Threads