Unload the Mother Form

slimimi

Well-known Member
Joined
May 27, 2008
Messages
532
Hi there - using excel 2003.

I have this simple code for a command button on an autoform.
As you can see - when the user clicks on the button it opens the frmPasswordSAVE

Code:
Private Sub cmdMODIFYtemplate_Click()
'Opens Password Checker which is frmPasswordSAVE
    frmPasswordSAVE.Show
    End Sub

Here is the code for the frmPasswordSAVE that i have to check for password entry

Code:
Private Sub cmdPASSok_Click()
    'Password Checker
    If Me.txtPASSWORD.Value <> "hundred" Then
        MsgBox "Incorrect Password", vbExclamation
        Me.txtPASSWORD.SetFocus
        Exit Sub
    End If
    If Me.txtPASSWORD.Value = "hundred" Then
        MsgBox "Correct Password"
    End If
        Unload Me
                    
    End Sub

As you can see - when you click the OK button - it checks the password and, if correct, unloads this form.

I would also like to unload the Mother form too which is called frmSAVElog

I tried entering this at the end :

unload frmSAVElog

but it did not work.

Any suggestions please?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I'm not sure here but I think you'd want to arrange the steps so that:

1) first you unload "other forms",
2) then you unload the current form.

It depends a bit on where you code is. If its in the form class, then once you unload the form ("Unload Me") then I'm not quite sure the code can finish any further instructions in the form (you've just destroyed the object).

In general, maybe put your code as much as possible in a standard module, so you don't lose instructions in the form objects - use the forms to get information and interact with the user, use standard modules to handle the program flow and processing.

I am not an expert on form applications - don't take my word for anything here.
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,525
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top