Using MS Access/User Login/Password help
Hey Mr. Rost,
My level of expertise is in the ballpark of intermediate and advanced using Access 2010.
My immediate question is: How to make a user login/password macro or VBA code.
I have a user table along with a query that lists all users with their appropriate password. The query has [Login ID], [Login Name], [Password]. I tried using an IF statement with a DLOOKUP code but seems its not working. Suggestions?
This is not a quick question to answer. I spend about half an hour explaining how to do this in my Access Security Seminar
, but logging on is just the tip of the iceberg. You then have to be able to control what your users can and cannot do in the database... and that's the really hard part. The rest of the seminar talks about that in detail.
You're on the right track, though. A DLOOKUP
statement is the way to go to verify their credentials. Set up a form with Username and Password fields. In the button code, you can say:
PasswordLookup = DLOOKUP("Password","UserTable","Username=""" & Username & """")
If Password = PasswordLookup then
And then you can, of course, direct them to the appropriate Main Menu or other form. Like I said, though, this is just the beginning. Now you have to know how to keep users out of your Navigation Pane, other forms, tables, your VB code, etc. Smart ones will know how to bypass your startup form, attach another database to your tables, etc. My seminar shows how to lock all of that down.