I have a password form with a text box and a command button, on click of the command button it checks that the correct password is entered in the text box, if it is it opens another form, if not a message box pops up informing an incorrect password has been entered.
When the form opens it is maximized.
I want to password form to close when the next form opens, 'DoCmd.Close,Form1,acSaveYes' after 'DoCmd.OpenForm,frmMainEmp' on the On Click event results in nothing happening at all.
'DoCmd.Close,Form1,acSaveYes' and 'DoCmd.Maximize' on the On Open event of the new form results in the password form maximizing and 'frmMainEmp' not opening.
Any idea what I am doing wrong here?
Form1 code
frmMainEmp code
note that I have removed my attempts to close Form1 from all coding at this stage.
Thanks in advance,
Mark
When the form opens it is maximized.
I want to password form to close when the next form opens, 'DoCmd.Close,Form1,acSaveYes' after 'DoCmd.OpenForm,frmMainEmp' on the On Click event results in nothing happening at all.
'DoCmd.Close,Form1,acSaveYes' and 'DoCmd.Maximize' on the On Open event of the new form results in the password form maximizing and 'frmMainEmp' not opening.
Any idea what I am doing wrong here?
Form1 code
Code:
Private Sub Command4_Click()
If Text2 = "admin123" Then
DoCmd.OpenForm "frmMainEmp"
Else
MsgBox ("Password Incorrect")
DoCmd.CancelEvent
End If
End Sub
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Form_Open_Err
DoCmd.Maximize
Form_Open_Exit:
Exit Sub
Form_Open_Err:
MsgBox Error$
Resume Form_Open_Exit
End Sub
Thanks in advance,
Mark