Novice Needs Help w/Password in Form

G

Guest

This is the code that I have, I need password1 to be any field in the
password column of the "instructors" table... I don't know how to do it, help
greatly appreciatd.

Private Sub Command29_Click()

If Password5 = "" Or Password5 = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
End If

'If correct password is entered open Employees form
'If incorrect password entered give message and exit sub

If Password5 = Password1 Then
DoCmd.GoToRecord , , acNewRec

Else
MsgBox "Sorry, you do not have access to this form", vbOKOnly,
"Important Information"
Exit Sub
End If
End Sub
 
G

Guest

Eric,

On your login form start with a Login combo box based off the instructor
table. Have the instructor name and password in the combo box but give the
password column a size of zero. Have a hidden field on your form called
ActualPassword. Then on the After Update of the login, put

Me.ActualPassword = Me.Login.Column(1)

This will take the password for that instructor and put it in the hidden
field. Then
have an unbound field on your form (EnterPassword) where they enter the
password (you can use an input mask).

Have a button to open the form you want to go to but on the On Click event
of that button (or on the After Update event of the EnterPassword field) put

If Me.EnterPassword = Me.ActualPassword then
DoCmd.Openform "frmNameofForm"
Else
MsgBox "Incorrect Password"
Exit Sub
End If

This is just a quick way to keep a form from being opened. It is not locked
down security since if someone knows Access, they could open the form from
the database window.

Hope this helps.
 
G

Guest

Thank you very much! I still need a little help.

I have adapted your method because I don't intend to open a new form, just
to verify the password before the button opens a new record... but now the
input password field stays filled in after I click a new form. Help
appreciated.

Thanks,
Eric
 
G

Guest

In your code, after the password is verified, put:

Me.EnterPassword = ""

Hope this helps.
 

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

Top