Close prev form if password-protected form opened

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have the following code that opens the password-protected form2. But I
also would like to have form 1 closed IF form2 is opened. Could anyone please
show me how this can be done? Any help much appreciated.


Private Sub Form_Open(Cancel As Integer)
Const strFormPassword As String = "password"

If InputBox("Please enter password") <> strFormPassword Then
MsgBox "Password incorrect. Please try again", vbOKOnly
Cancel = True
End If
End Sub
 
Close form 1 in the Form_Load event of form 2. The Form_Load event will not
occur if Form_Open is cancelled.

Max
 
Back
Top