Password Protect Forms

K

Katrina

I want to Password protect only one form in a database. I don't need to
check for usernames or anything, I just basically want a popup box that
prompts for a password and will not allow you to open the form without the
password.

I'm sure there is simple code for this. Any Suggestions?

Thanks
 
D

Dave Elliott

Here is one that I use
Create a form named frmPassword
Add two fields; one named Text0 with a input mask of password, unbound.
Add another command button and under the on click event use this code;
Naturally you call this form when a user tries to open the form you want
protected.

Here is the code, substitue your form name to open and password
If IsNull(Forms!frmPassword!Text0.Value) Then
MsgBox "You cannot enter a blank Password. Try again."
Me!Text0.SetFocus


Else
End If

If (Forms!frmPassword!Text0 = "administrator") Then

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Orders"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, Me.Name



Else: MsgBox "Wrong Password, Try again."

End If
 
M

Michelle Lee

Hi Dave Elliott,

Can this frmPassword be used to open two different forms but with the same
password?
 
Top