Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigation Buttons

Status
Not open for further replies.

Joesun

Programmer
Dec 18, 2002
3
MV
Hi All,

In my test project, i included four buttons for navigation apart from system class.

Ie. TOP,PREVIOUS,NEXT,END.

Here when i at first record - top/previous should be disbled like system class. Also, when i at last record of the dbf next/last should be disabled.

Click procedure in top and last button, all buttons are working successfully.

But, when i navigate through next button, it disabled after encountered eof(). let's say, dbf having 20 records, it is disabled after generating recno() 21.

How can i disable the next button when i navigate at 20th record and disable the previous button when i at first record?

All efforts would be highly appreciated!

TIA

Joe
 
Hi Joe,

Since the Record pointer in the Beginning & End of the File the controls looks like disabled.

So, Use the following conditions before navigating in your command buttons.

*** IN THE PREV BUTTON
IF NOT BOF ()
SKIP -1
ENDIF


** IN THE TOP BUTTON
IF NOT BOF ()
GO TOP
ENDIF

*** IN THE NEXT BUTTON

IF NOT EOF ()
SKIP
ENDIF

*** IN THE LAST BUTTON

IF NOT EOF ()
GO BOTTOM
ENDIF


HTH

Suggestions Invited...


[smile] gchandrujs [sunshine]

 
Gchandrujs ,

For the Next button, you suggested:

IF NOT EOF ()
SKIP
ENDIF

That won't work. EOF() is not detected until after the SKIP, that is, when you are already on the e.o.f. marker and you try to skip forward again.

The way to deal with it is like this:
SKIP
IF EOF()
SKIP -1
ENDIF

Looks a bit clumsy, but it works.
Mike Lewis
Edinburgh, Scotland
 
gchandrujs,

I gave like that, but it is not disabling when encoutering the last record also the first record.

i gave like that:

if !eof()
skip 1
thisform.refresh()
endif

if !bof()
skip -1
thisform.refresh()
endif

wot wrong with it?

TIA

Joesun
 

Joesun, while I'm sure there are other ways around this, I had the same problem some time ago, which I fixed by putting the following code in the INIT method for the form, after the table was opened. Also, create 2 form properties, as shown below.

Code:
GO BOTT
THIS.endrec = RECNO()

GO TOP
THIS.begrec = RECNO()

Good luck!

Al

 
Have a look at my CrownBase app,
in the classlibrary: 'busobj_lib' there is a class 'bus_obj'.
In this class I implemented the navigation through records.
(see link in my signature)

HTH,

Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Joe

How can i disable the next button when i navigate at 20th record and disable the previous button when i at first record?

In the Next Button add

SkIP
If Eof ()
SKIP -1
THISFORM.REFRESH ()
THIS.ENABLED = .F.
ENDIF

Use the same accordingly in the PREV button.

To Enable the Same in the PREV button

IF THISFORM.CMDNEXT.ENABLED = .F.
THISFORM.CMDNEXT.ENABLED = .T.
ENDIF
Use accordingly in NEXT Button.

Suggestions Invited...

[smile] gchandrujs [sunshine]




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top