Password Protecting Buttons

Ollie_3670

Registered User.
Local time
Today, 12:22
Joined
Feb 1, 2010
Messages
50
I'm hoping to password protect the Access 2007 application using a automatic start up form with a password to allow people to continue to the main menu.

I'm hoping to have two levels of password, an admin and regular user. I was hoping to hide certain buttons and labels to the regular users (such as staff information).

Is it possible to do this? Or will I have to duplicate forms and depending on the password send the user to a different side of "the tree". Which will be far from ideal..but feasible..just!

Thanks ! :)
 
Check the user's rights against your "users & permissions" table, then set the Visible property of the command button accordingly using VBA
 
Right great, I thought that would be the way if any. I'll implement all the buttons now and google the VBA code at a later date! Thanks!
 
You're welcome. An alternative approach would be to set the button's Enabled property instead? Or you actually don't want them visible/invisible?
 
Temptation is a horrible thing! I'd prefer them not to know what they could see, if you catch my drift! :D

Unless it's substantially easier to do, i.e. with minimal code. Then I'll just pass it off as an oversight if anyone asks ;)
 
Same length of code I would imagine. It's all up to you as to how you want it represented, as long it doesn't mess with the layout of your other controls - in terms of having to move them whilst changing the Visible property.

Naturally, you only hide sections of a db or controls that are not relevant to the user and you disable controls that the user should not have access to. Just a rule-of-thumb most people would follow.

Good luck.
 
What's the general idea with the code? Is it something like:

Password = PasswordTextBox

if Password = Admin then
ViewStaffPayrollButton = ViewstaffPayrollButton.Enabled

(NB: Obviously in VBA not pseudocode)
 
I would say check against the UserGroups field rather than password. There should be three columns, something like: Username, Password, UserGroup. Your UserGroup would contain "Admin" and "User". So with that in mind the syntax would be like:

Code:
Dim userGrp as string

userGrp = DLookup("[UserGroup]", "NameOfSecurityTable", "[UserName] = '" & user & "'")
If Lcase(userGroup) = "user" Then
     button1.visible = False
Else
    button1.visible = True
End If
 

Users who are viewing this thread

Back
Top Bottom