In the db, I have a tUsers table, with userID, Name, and Level
USERID, Name, LEVEL
bob12, bob smith, M
pam4, pam jones,""
xman1, charles xavier, A
when user opens the db, the main menu form will open and grab the userID.
Then lookup that persons rights in order to enable/disable controls.
put the UserId into an invisible text box on the form,txtUserID , so queries can see it.
Code:
public gvUserID
sub form_load()
dim vLevel
gvUserID = Environ("Username") 'get userID,visible in all forms
'get level from user table
vLevel = Dlookup("[Level]","tUsers","[userID]='" & gvUserID & "'")
'now, enable/disable items on form
select case vLevel
case "A" 'admin
'all is enabled
case "U" 'normal user
txtBox1.enabled = false
txtManager.enabled = false
case "M" 'manager
txtBox1.enabled = false
end select
end sub
now use queries that filter on the textbox txtUserID so users can only see THEIR data:
select * from table where [userid]=forms!fMyform!txtUserID
or join a table with the users lists and what they can open.