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

How to link button to a pageframe of another form

Status
Not open for further replies.

eyeshield21

Programmer
Aug 13, 2014
62
PH
What i want is that if i press a button then the current form will close
and loads another form with a specific pageframe is activated..
im stuck at this code...
Thisform.release
do form c:\folder\form.scx...

thanks in advance
 
A couple of solutions come to mind.

First, you can do the whole thing in the click event of the button, like this:

Code:
DO FORM SecondForm NAME oForm      && do this before you release the main form
oForm.PageFrame1.ActivePage = 3    && goes to page 3
THISFORM.Release

However, there's a big snag in that approach. The object reference (oForm in tnis example) needs to remain in scope while SecondForm is active. If it is a local variable (local to the click of the command button), SecondForm will disappear when oForm goes out of scope. That suggests that oForm needs to be a public variable, which is geneally frowned on, or a property of some global application class.

My preferred approach would be to pass a parameter to SecondForm:

Code:
DO FORM SecondForm WITH 3
THISFORM.Release

Then, in the Init of the second form:

Code:
LPARAMETERS tnPageNo
IF NOT EMPTY(tnPageNo)
  THISFORM.PageFrame1.ActivePage = tnPageNo
ENDIF

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top