Password Form

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

Guest

Does anyone have any simple instructions to implement a password form to
allow access to a restricted subform?

Thanks.
Iram/mcp
 
Hi Iram

You would be better using user level security than a self made simple form.

At the very basic you could use a text box to input text and if the text did
not = what was needed then you can't go to the form. BUT "anyone" with even
a very basic knowledge of access will get round this
This sort of thing

Private Sub TextBoxName_Click()
Static Counter As Integer
If TextBoxName = "SomeText" Then
DoCmd.OpenForm "SomeForm", acNormal, "", "", , acNormal
DoCmd.Close acForm, "PasswordForm"
Else
If Counter < 2 Then
MsgBox "Some text here - try again - Max 3 attempts", vbOKOnly,
"Some title"
Counter = Counter + 1
TextBoxName = ""
Else
DoCmd.Quit
End If
End If
End Sub


But you may want to look at this link
http://support.microsoft.com/default.aspx/kb/207793/en-us
download the paper and study it then
______________________________________
PRACTICE ON A BACKUP OF YOUR DATABASE
______________________________________

or you may be "very" upset if you can't get into your own DB

Note that even this method can be "got-around" but it's worth giving a trying

good luck
 
Hello Wayne-I-M.

I have copied your code to the "On Click" of a button next to the password
text field.

Private Sub PasswordInput_Click()
Static Counter As Integer
If PasswordInput = "123456" Then
DoCmd.OpenForm "Switchboard", acNormal, "", "", , acNormal
DoCmd.close acForm, "PasswordForm"
Else
If Counter < 2 Then
MsgBox("You haved typed the wrong password, your attempts are being
logged - try again - Max 3 attempts", VbMsgBoxStyle = OKOnly, "PasswordForm")
As VbMsgBoxResult
Counter = Counter + 1
PasswordInput = ""
Else
DoCmd.Quit
End If
End Sub


When I compile the form I keep getting this error on the MsgBox... line

Compile error:
Statement invalid outside Type block.

Could you tell me what I am doing wrong?

Thanks.
Iram/mcp
 
I'm not sure whether this is the problem, but you're missing an End If
statement. If you look at Wayne's suggestion, you'll see his code ended

DoCmd.Quit
End If
End If
End Sub

while yours just ends

DoCmd.Quit
End If
End Sub
 
Back
Top