>I have so many private variables and cursors which I will have to reset before opening the next records
Well, you can't have private variables in forms anyway. Or let me put it this way: Whatever you do in Load or Init, eg creating private variables, goes on the stack and back, so private variables you have during these events are released and not available in the rest of the form life. The only way to have private variables is by defining them before a DO FORM or CREATEOBJECT("formclass") and only, when the code making that call does not finish, for example via a modal form or a READ after starting a nonmodal form. Still you have a modal state, as that's the only way private variables stay in scope.
A way to quit your form and start it again for another record would involve releasing the form and starting it from the level of the initial call, so eg you do
Code:
ShowRecord=1
Do While ShowRecord<>0
* private variable assignments
Do Form yourform
Enddo
Yourform needs to be modal to stop execution of the While loop before releasing. Yourform then has access to ShowRecord variable, as it's really private and still on the stack, when the form runs. Now when some button on the form sets ShowRecord=0 and releses the form quits overall, if it sets ShowRecord to another number, eg the recno you want to display next, the form is restarted after it has finished.
You can't do that inside the form itself, you have to step back one level from the stack, so that calling loop has to be outside.
It's a hack and not recommended, just like not needing public or private variables overall.
Information needed throughout the form should be turned into form properties. Using OOP and form classes you could do oForm=CreateObject("yourform") and before making that new form visible set predefined user properties, you can also pass in parameters via oForm=CreateObject("yourform", param1, param2) and receive them in form init via LPARAMETERS tcParam1, tcParam2. The calling can also be DO FORM yourform WITH param1,param2.
Besides that you could in a first step also simply try to reuse already existing variable, put your initalisation into a separate userinit() method of your form and call that from the init event and also when you want to change record, so you have a form initialisation for your own needs not redoing the form overall. That will then also make the outer loop unnecessary, as it hinders you to use the menu it's really ugly.
The ideal application design will use non-modal forms, self contained, only with simple initialization parameterization, you mainly ill need the ID, primary key of one specific record, if your form is a single record form. A private datasession is recommended, especially when you don't want to show one record only, but let a user start forms from list clicks and by that show many records in parallel each in its own satellite form. It should get clear, that private variables then are also deadly, same form runs multiple times with same variable names => not working. Properties are really private to each form => works.
You can't get a legacy design running with the new VFP, what once worked is now obsolete with new techniques.
Bye, Olaf.