username and password integration into form

AC-Dev

What say you, good sir?
Local time
Today, 17:52
Joined
Jun 20, 2011
Messages
81
Hi all,

I currently have a table for employees which holds the first name, last name, id, password, and their access level to the database. basically what i want to do is - on start up - have the user enter their employee number and their password. i have the input boxes set up already in another section of the database but i want to move it to the start up (as i already said). when they enter the correct username/password, i want "Welcome, firstName lastName" to apprear in the top of the switchoard. i am just not sure how to get the code to call for the username and then check if the password matches it.

Here is my code for the username and password



Private Sub btnMaintenance_Click()

On Error GoTo Err_cmdbtnMaintenance_Click
'Attached to On Click event of cmdOpenEmpForm

Dim strempID
Dim strPasswd


strempID = InputBox("Enter Employee ID", "Restricted Form")

'Check to see if there is any entry made to input box, or if
'cancel button is pressed. If no entry made then exit sub.
If strempID = "" Or strempID = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
ElseIf strempID = "XXXXXX" Then
strPasswd = InputBoxDK("Enter Password", "Restricted Form")
Else
MsgBox "Sorry, you do not have access to this form", _
vbOKOnly, "Invalid User"
Exit Sub
End If

If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
ElseIf strPasswd = "XXXXXX" Then
DoCmd.OpenForm "Maintenance Form", acNormal
Else
MsgBox "Incorrect Password!", _
vbOKOnly, "OOPS!"
Exit Sub
End If
Exit_cmdBtnMaintenance_Click:
Exit Sub

Err_cmdbtnMaintenance_Click:
MsgBox Err.Description
Resume Exit_cmdBtnMaintenance_Click

End Sub


Help please!
 
You could use DLookup here, but having passwords stored in tables like this isn't really the best way of securing your database. For example you can bypass all the startup forms and get access to the tables simply by holding the shift key as you open the database.

You're better off using the security wizard in Access and granting permission for each user to the forms they're allowed to use.
 
that sounds like a better idea lol
how would i go about doing that?
 
i should have specified im using access 2010
 
Well - I've only ever used Access 2007 but I'm pretty sure there is a user level security wizard on there too, have a look in the help file, it'll explain everything.
 
ive googled it and apparently there is none. ill do a search in the help anyway
 

Users who are viewing this thread

Back
Top Bottom