Subject Re: [IBO] EOF BOF craziness
Author Paul Hope
Hi Daniel

> At September 8, 2003, 11:44, Paul Hope wrote:
>
> > Just place a TIB_Query, TIB_Dataset and TIB_Text on a form and link them
up.
> > Also 2 buttons (for next and prior).
> > In the form OnCreate open the query. Under the first button put
Query.Prior
> > and the second put Query.Next.
>
> > Using the Next/Prior will give the 'at end/beginning of dataset' error.
>
> > then under the buttons put
>
> > if not eof then next and if not bof then prior.
>
> > You will notice that the IB_Text goes blank when each end is reached -
> > because the current row (one past the end) is invalid.
>
> > I need it to stop on the last/first valid record because in reality I am
> > doing a lot more.
>
> Try the following code examples:
>
> For Next:
> if not eof then
> next;
> {The "not bof" is to make sure the result set is not empty}
> if eof and not bof then
> last;
>
> For Prior:
> if not bof then
> prior;
> {The "not bof" is to make sure the result set is not empty}
> if bof and not eof then
> first;
>
> These code examples will work with TIB_Query, but not with TIB_Cursor
> because TIB_Cursor doesn't support the same methods.
>
This has nothing to do with the problem - I agree the above work fine. The
last next will point at a blank record but the loop will exit because eof is
now true. In other words the processing is done on each row before next is
called. In the case of stepping through using visual controls we call next
before processing (looking at) each row.

Regards
Paul