VB 6 question about forms

Codewiz

Diamond Member
Jan 23, 2002
5,758
0
76
have written a program that utilizes two forms. I only show one form at a time and allow for the user to switch back and forth between them using control buttons. How can I setup my main form so that the "X" button at the top right unloads both forms?

How can I setup the "X" button on the summary form to unload the summary form but make the Main form visible.

I want the main "X" to completely exit the program while the summary "X" to close that form and make the main form visible.

Sorry about the easy question but I can't find the answer.
 

BuckleDownBen

Banned
Jun 11, 2001
519
0
0
in the Form QueryUnload event, put the appropriate code. There is a parameter called UnlaodMode that tells you if the form is closing because the X was clicked(1) or through code(0). In the summary form, if this parameter is 0 do nothing. If it is 1 then do frmMain.Show.

In the main form, you can do Unload frmSummary in the QueryUnload event.
 

bunker

Lifer
Apr 23, 2001
10,572
0
71
You could also set up both forms as subforms in one main form. That way when you close the main form both subforms go.