Disable button on user id

Tupacmoche

Registered User.
Local time
Today, 12:12
Joined
Apr 28, 2008
Messages
291
Hi Form Masters,

I'm using the following code to disable a button on a form. Only the user in the code can use the button. I can foresee that this can become a disaster. Any suggestions on how to improve it?

Private Sub Form_Load()
If GetCurrUser = "Robert Semo" Or GetCurrUser = "Pass Rey" Or GetCurrUser = "Elizabeth Plla" Or _
GetCurrUser = "Andrew Moades" Or GetCurrUser = "Travis Simms" Or GetCurrUser = "Erica Glee" Or GetCurrUser = "Mee Lay" Or GetCurrUser = "Chris Reeby" Then
Me.btnDEC.Enabled = True
Else
Me.btnDEC.Enabled = False
End If
End Sub
 
Put those names in a table and if not found disable the button.
That way if the users ever change all you change is the data in the table.
 
Agree with Gasman that your approach is wrong.

I'd suggest a slightly different approach
Add a yes/no field to your user table.
Set the value true only for those who can use the button
 
Create an emloyees table with ID, Name, lvl



Lvl 1 = admin all others lvl 2


you just look up the lvl for the employee online if 1 is returned enable button
 
Hi MickJav,

I made the attached table. Now how do, I set/use it in my code?
 

Attachments

  • AccessRights.JPG
    AccessRights.JPG
    23.9 KB · Views: 84
Hi MickJav,

I made the attached table. Now how do, I set/use it in my code?

All of your users have the same rights number. You will not be able to differentiate between them for access permissions... they can all do the same thing.

Is it safe to assume your users have to log into your database? There is a users table storing their usernames and passwords?
 

Users who are viewing this thread

Back
Top Bottom