I assume the intention of the DO WHILE .T. is to keep the menu shown. If so, then change your main to use READ EVENTS instead. This puts VFP into a state waiting for events to occur. Assuming the oBMENU object is declared earlier as either Private or Public, it will stay in scope, e.g.
oBMENU = NEWOBJECT("MainMenu","chrommmainform.prg",'',lcBAckControl)
OBMENU.SHOW(1)
READ EVENTS
also assuming that when you close the OBMENU form, you want the app to close, in your OBMENU.Unload() event put
CLEAR EVENTS
You won't need the
relase obmenu
>I am writing a system which uses a form with buttons as a main menu. When the uses selects a button a program is run (report, data input screen, etc.) and then they should return to the main form. I load the form as an object from main.prg. My problem is when I go to show the form again in the main.prg the object is no longer valid. This program works initally but crashes at OBMENU.SHOW(1) after it returns from running 'do ChrmReport'.
>
>
>*Main.prg
>oBMENU = NEWOBJECT("MainMenu","chrommmainform.prg",'',lcBAckControl)
>DO WHILE .t.
> * display the menu
> OBMENU.SHOW(1)
>enddo
>RELEASE obmenu
>
>
>The code in the button being run is
>
>
>DEFINE CLASS cmdReport as label
> NAME = "cmdReport"
> caption = 'REPORTS'
> PROCEDURE CLICK
> thisform.deactivate()
> DO CHRMReport
> thisform.activate()
> ENDPROC
>ENDDEFINE
>
Insanity: Doing the same thing over and over and expecting different results.