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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pageframe and record positioning controls 2

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,795
10
38
JP
All,
I'm experiamenting with Page Frames, and have run into a snag, that I'm sure many of you have faced. I have a Pageframe with 5 Pages on it. Each tab represents a different data table. I would like to have a single set of buttons to control the Pages, without writing in hard code to deal with each page. So, what I would like to do is have something like a "Next" button, that regardless of what page I have selected, it moves the record pointer for the right table. What I don't want is some giant case statment in my Next Button. From an OOP standpoint, I thought this would be a great time to put it to use, but I'm not sure what the best way to go about that is.
I wanted to create a Method for the Page that can be called by the "Next" button, but I have not found a way to do that by page. (Is this making any sense???)
Please help if you can.

Many thanks.
Thanks,
-Scott

s-) Please let me know if this has helped s-)
 
What you could do is the following:

As I understand is that you wish to skip a record in the table of which the records are shown on the current active page.

*- Make a custom method in the pageframe.
*- Call this method from you next button.
*- In the custom method, implement a parameter toPage.
*- In each page, create at runtime a property that stores the alias of the table of which the data is shown on that page.
In your custom method wrtie something like this:

LPARAMETERS toPage

toPage = IIF(VARTYPE(toPage) == 'O', toPage, .NULL.)

IF !ISNULL(toPage)
SELECT toPage.cAlias
*- Take care of the EOF etc. checks
SKIP 1
toPage.Refresh()
ENDIF


In your nxt button write:

*- Given the button is on the pageframe itself
*- and your custom method is called NextRecpage
THIS.PARENT.NextRecPage(THIS.PARENT.ActivePage)


I hope this is clear enough. If not, feel free to ask for more...;-)

of course the parameter statement is not really necessary since the pageframe itself is already familiar with the Activepage.

So instead you could write:

SELECT THIS.ACTIVEPAGE.cAlias
*- Take care of the EOF etc. checks
SKIP 1
THIS.ACTIVEPAGE.Refresh()
ENDIF

HTH,
Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Or:
Put an Command Button in the Form to Navigate Record By Record.
in The Next Button, Refresh each page. By example:
BotonNextRecord.Click:
LOCAL oControl, oPage
SKIP
FOR each oControl IN THISFORM.Controls
if oControl.BaseClass = "Pageframe"
FOR EACH oPage IN oControl.Pages
oPage.Refresh()
ENDFOR
endif
ENDFOR
Put Other command Button in The Form, to Navigate Page By Page:
BotonNextPage.Click:
LOCAL oControl, oPage, lnpag
FOR each oControl IN THISFORM.Controls
if oControl.BaseClass = "Pageframe"
if oControl.ActivePage < oControl.PageCount
lnpag = oControl.ActivePage
oControl.ActivePage = lnpag + 1
else
oControl.ActivePage = 1
endif
endif
ENDFOR
 
Surely it's just as simple as selecting the alias of the table on each pageframe in the setfocus method? Then when you do your skip in the Next buttons click event, you are on the right table to move the pointer.
 
Finsys,
Basically, you are correct, but my example here is for the &quot;Simplest&quot; issue. I am already doing that, but when you get into complicated issues, such as adding a new record, that becomes a little more complicated. In this case, I have a set of record positioning controls, Edit, Add, Save, Cancel and Delete. They are all on the Form, not on the PageFrame. However, I want to use them to control the PageFrame, without building a bunch of &quot;CASE&quot; statments into the control, so that the controls remain genaric on every form, whether they have a PageFrame on them or not, and regardless of the number of pages in the PageFrame.
Using Weedz suggestion, I have made some success. The trouble here is, using the Class Browser, I'm able to add a method to the PageFrame subcalss I created, but I'm not able to add a method to the Page(s) within the subclass. Is it possible to do that? So that I can then call something like:

ThisForm.myPageFrame1.ActivePage.AddRecord()

Thanks again.

Thanks,
-Scott

s-) Please let me know if this has helped s-)
 
Hi Scott,

You could make a coded class representing a page and add your pages at runtime, but this would be troublesome.

A rule of thumb is to let the parent take care of its children and not to talk to the children directly.

In this case, the page you are refreshing, updating etc is the parent's (the pageframe) activepage.

So the best thing to do is to get the alias from the activepage and handle the additioon of the record from the form level.

Even better would be to do the following:

Make a base class that you are using as a business object. In this baseclass of type container, you would handle all datahandling. Adding, updating etc.

The way to go is then the following:

Put this container class on your form.
From your buttons, call the methods to add or update records.

In this business object, you would have method like next , previous, last and first. Make all data navigation relative. Meaning: always refer to an alias that you require from the business object.
So just make a mehtod called GetAlias() and SEtAlias() both referring to a protected property cAlias.

So you Last() method would be:

lcAlias = THIS.GetAlais()
GO BOTTOM IN &lcAlias

The next step would be, drop the container on your form.
Drop your pageframe on your container.
Following this, put in the activate event of each page, the call: THIS.PARENT.PARENT.SetAlais(THis.cAlias), in which THIS.cAlais would be the alias of the table represented on the active page.

In this way, every method called from your business object would have effect on the alias of the current page.

So the structure would be:

FORM
BUSINESS OBJECT
PAGEFRAME
PAGES

To do it even more nice, you could make a business form baseclass, having the business object container already on it, and the buttons would call methods of the form, calling the methods of the business object (Last, First, Next, Add etc.).

Button.Click => Form.Last() = > Busines.last()

The business form could be used for any maintenance screen and the business object could be used for any data handling.

In essence, this is somewhat the structure used in VFP CodeBook framework...so its not entirely mine...;-)

HTH,
Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Try this:

Create a form property called &quot;CurTable&quot;

In the &quot;ACTIVATE&quot; event of each page of your pageframe, set this property to that page's table alias. For example:
Code:
thisform.CurTable=&quot;customers&quot;
Then, in your button code, use the property:
Code:
SELECT (thisform.CurTable)
REPLACE ... IN (thisform.CurTable)
GOTO TOP IN (thisform.CurTable)
SKIP IN (thisform.CurTable)
SKIP -1 IN (thisform.CurTable)
 
HI Maniac,
In the activate event of each pageFrame, add the code..
SELECT myAlias && the alias related to that page.

In the buttons which are at the bottom of the form common to all the page frames..

Each PageFrame. ACtvateEvent
----------------------------
Select myTable && the table in that pageframe

NextButton.Click Event
----------------------
IF ! EOF()
SKIP
ENDIF
IF EOF()
LOCATE && or go bottom
ENDIF

PriorButton.ClickEvent
----------------------
IF ! BOF()
SKIP -1
ENDIF

FirstRecordButton.ClickEvent
----------------------------
LOCATE

LastRecordButton.ClickEvent
----------------------------
GO BOTTOM

Hope this helps :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Weedz & Ramani,
Well, as usual, you guys come through for me again. Thanks for all your help.

Thanks,
-Scott

s-) Please let me know if this has helped s-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top