From withtin a form, how do you open a new form with the click of a button, please help....
Printable View
From withtin a form, how do you open a new form with the click of a button, please help....
assuming the form is created
Load frmYourForm
frmYourForm.Show
Well, ok asume that the first form is called menu.frm and the second form is called menu2.frm, where would I put that code and how would the code go, (for loading when a button was clicked)
Code:weird naming convention? However...
'any click event of any control on form menu.frm
unload menu.frm
load menu2.frm
menu2.show
'on form menu2.frm you would revers the order
Code:
'Command1, I am assuming is the name of your button
Private sub Command1_Click()
menu2.Show
'If you want to hide the first form, just use
'menu1.hide
'otherwise the menu2 form with be shown ontop of the first
End sub
It's a good idea to use Unload when you want to get rid of the Form.
Code:Unload Form1
Well, this is my code:
Private Sub Command10_Click()
Unload menu1.frm
Load menu2.frm
menu2.Show
End Sub
and this is the return code:
Unload menu2.frm
Load menu1.frm
menu1.Show
Now what did I do?! I get an error saying An object is required. Help?
it should look like:
Leave off the .frmCode:
Private Sub Command10_Click()
Unload menu1
Load menu2
menu2.Show
End Sub
'take the . out of your names
call it frmMenu2 and frmMenu
Private Sub Command10_Click()
Unload frmMenu
Load frmMenu2
frmMenu2.Show
End Sub
and this is the return code:
Unload frmMenu2
Load frmMenu1
frmMenu1.Show
You could also set frmmenu2 to nothing, which would clear up any resources still running.
Code:Unload frmMenu2
Set frmMenu2 = Nothing
Load frmMenu1
frmMenu1.Show
You don't even have to use Load frmMenu2 if it isn't loaded then frmMenu2.show will load it.
Load
frmMenu2.Load, stores the form in memory and executes the Load event of the form. It doesn't show on your desktop, but is waiting rearing to go.
Show
frmMenu2.Show, if not loaded previous executes the Load event and displays the form on your screen.
Hide
frmMenu2.Hide, the form is still in memory but is not displayed. generally used if you are going to re-display the form but want to keep it in memory.
Hope that it clear.
Then you can use Unload to destory the Form and release it from memory.
Code:Unload Form1
Set Form1 = Nothing