Password Form open

Lenovo123

New member
Local time
Yesterday, 21:18
Joined
Dec 14, 2015
Messages
9
Hi Guys,

apologies if this has been covered but can not seem to find it;

problem is that the below code does not work on my db. It asks for the password but even if i enter an incorrect password it still opens the DB albeit after the pop up message saying Invalid Password, Please try again.

Private Sub Form_Load()

Dim PassWord As String
PassWord = InputBox("Please Enter Administrator Password")
If PassWord = "admin123" Then
DoCmd.OpenForm "formname"
Else
MsgBox ("Invalid Password, Please try again.")
DoCmd.Close
End If

End Sub

many many thanks!

Bill
 
Use Application.Quit instead DoCmd.Close (which closes form only)
 
Use Application.Quit instead DoCmd.Close (which closes form only)

Will this quit the whole access program? I just need the form to be closed.

The form is opened via a 'welcome page' (another form) with a button link hence the prompt for a password.

Thanks!!

Bill
 
Will this quit the whole access program? I just need the form to be closed.

It will, yes. But you didn't say in your first post what exactly would you like to achieve :)
Does your code (on wrong password entered) close the form but still opens database? Or does it open form that shouldn't be open ("formname")?


The form is opened via a 'welcome page' (another form) with a button link hence the prompt for a password.

So what exactly should happen when someone enters wrong password?
 

Users who are viewing this thread

Back
Top Bottom