Close prev form if password-protected form opened

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
 
M

Max Smart

Close form 1 in the Form_Load event of form 2. The Form_Load event will not
occur if Form_Open is cancelled.

Max
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top