Password protecting buttons

dcarr

Trainee Database Analyst
Local time
Today, 22:43
Joined
Jun 19, 2002
Messages
112
Is there any way in which you can create two accounts on your database one for user one for admin, hiding certain buttons, or locking the buttons if you are not an admin user?
 
You can tell who is logged in by using the CURRENTUSER constant. You can then write some code on the OnOpen event:

if currentuser="YourUserName" then
me.yourcontrol.visible=true
else
me.yourcontrol.visible=false
end if
 
Thanks for that Bill. Say I was to have two types of user 'student' and 'admin' and wanted both to log in then initiate the code you provided how do I go about doing this?
Many thanks
 
What I usually do in this case, is that I have a table called tblUserProfile that has the information for all of the users of the database (including their username, and group). When the database is opened, have a hidden form open that check the CURRENTUSER contant to find out who has just logged on, and contains all of their information. By keeping this form open all of the time, you can refer back to this information at any time in your code or queries.

Note: This can only be done in a Frontend/Backend database.
 
Can you not use the security wizard on your database to create a simple login window? I have tried using the wizard but keep getting an error upon adding users. The error reads cannot setfocus on table tblUserName? Any ideas
 
You can not set focus on tblUserName, because it does not exist. You will have to create it yourself. I realize that this makes for some double entry, but I find the benefits make it worthwhile in your case.
 
I have created the table tbUserName as requested by the error message. I have created three columns Username, Password, and group. I have populated the fields but I still receive the same error messages, any ideas? Thanks for your help
 

Users who are viewing this thread

Back
Top Bottom