using password to open form

  • Thread starter Thread starter Fred Thomas
  • Start date Start date
F

Fred Thomas

Two questions, both have to do with a form that I want to
open only after a password is accepted. The password is
entered into textbox "txtPassword" in form "frmPassword"
the form I wish to open is "frmSecondarys. I assigned the
following code to the txtPassword "On Click" event:

Private Sub txtPassword_Enter()
Dim pass As String
pass = administration
If pass = txtPassword Then
DoCmd.OpenForm "frmSecondarys", , , , acFormEdit
Else: MsgBox "Try again!"
End If
DoCmd.txtPassword.SetFocus
End Sub

Needless to say this does not wrork.
First question what should be here?

Second question, is there a way to hid the password as its
being typed in, saw with asterisks.
Really new to this programming thing. TIA
 
HI Fred!
I think in order for your password form to work better is
to have a txtBox( to enter password) called txtPassword
and a button that validates password.

So I would write in the 'Click event' of that button the
required validation code, and depending on the result you
either sent the user to the right form or tell him that
the password is no good.

Code inside button: (in the 'click event' of your
validation button.

Dim pass As String
pass = "Administration"
If pass = Me.txtPassword.Value Then
DoCmd.OpenForm "frmSecondarys"
Else
MsgBox "Try again!"
Me.txtPassword.SetFocus
End If

This should work OK,
PAtrick
 
Back
Top