Reputation: 33
I'm using Access 2013.
I want to disable buttons on some forms based on the user that is logged into the computer.
I'm using code from Dev Ashish to determine the name of the logged in user to the computer.
The username is stored in global variable LoggedInUser
I have a table called "Users" in which I am storing the login emails for the admins who need expanded functions. This table along with other fields has the following fields: "Email" Short Text "Active" yes/no
I want to check if the logged in user exists in the users table and if they are marked as Active.
I then want a global boolean variable called AuthUser to hold a true/false for if the user exists in the table and is active or not.
I think this might need to be done with a dlookup or dcount, but I just can't seem to make it work - any ideas on a solution?
Upvotes: 0
Views: 400
Reputation: 5386
You haven't shown your query that doesn't work?
I can guess - and you can tell me I guessed wrong Here's something you can play with
dim rs as DAO.Recordset
strSQL = "SELECT Username from Users WHERE [Username] = """ & LoggedInUser & """ AND [Active]"
set rs = currentdb.openrecordset(strSQL)
AuthUser = Not rs.EOF
rs.close
Upvotes: 0