Home > Software engineering >  This form should be closed
This form should be closed

Time:09-22

I have three forms, main form, A child form B and C, and now I can through A window open B and C, and now I want to do is click A form button after open B form, the form A close at the same time, when click the X B form closed B form close A window open at the same time, this program should be how to do

CodePudding user response:

 'FormA 
'put a CommandButton
Option Explicit

Private Sub Command1_Click ()
Me. Hide
FormB. Show vbModal
Me. Show
End Sub

CodePudding user response:

This is easy,

Reference:
 Option Explicit 

'" A form of "code:
Private Sub Command1_Click ()
Unload Me 'if there is not anything "variable" in A form that can be "uninstall the form"
'if you have any input on A form, or A different "choice" project needs to retain,
'then you cannot Unload, only "hidden window", use: Me. Hide
Form2. Show
End Sub

 Option Explicit 

'" form B "code:
Private Sub Form_Unload (Cancel As Integer)
Form1. Show 'shows A form
End Sub

CodePudding user response:

Upstairs friend, why I tried it in the way you not line

CodePudding user response:

I'm B form closed on display A form at the same time, but now does not display

CodePudding user response:

You check whether correct the use of "my code,


Second, is the form of the corresponding problem, I here Form1 is assumed as A form, Form2 assumption for B form,
If the "required to do", is certainly no problem,
  •  Tags:  
  • VBA
  • Related