Hello, I am trying to set up username and passwords in my data base(access 2007), I have it set up to accept usernames and passwords using vba, but I had to write the username and password into the code. I would like for it to look at a table I created called Users and determine if the username and password are valid. This is what I have now,
If Username = "Tim" And Password = "Rocks" Then
MsgBox "Access Granted", vbInformation, "ViciLife"
MsgBox "Welcome", vbInformation, "ViciLIfe"
DoCmd.Close
DoCmd.OpenForm "Switchboard"
DoCmd.ShowToolbar "Ribbon", acToolbarYes
DoCmd.SelectObject acForm, NavPane, True
ElseIf Username = "User" And Password = "Password" Then
MsgBox "Access Granted", vbInformation, "ViciLife"
MsgBox "Welcome", vbInformation, "ViciLIfe"
DoCmd.Close
DoCmd.OpenForm "Switchboard"
DoCmd.LockNavigationPane True
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.SelectObject acForm, NavPane, True
RunCommand acCmdWindowHide
Else: MsgBox "Please re-enter your Username and Password."
End If
This is so if tim enters his user name and password the database opens with admin privileges, if the default "user" and "password" are entered the ribbon and nav pane are hidden. I would like to set it up so that instead of the code actually saying username = "tim" and password = "rocks" it would reference the username and password field of my Users table, and if tim and rocks is in the users table( or what is entered in the text boxes) it would perform the rest of the code. Any help would be greatly appreciated.
Also this code is in the button click event of a form with 2 textboxes named "Username" and "Password"