Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

disabling controls based on User Security

Status
Not open for further replies.

dhanson

IS-IT--Management
Dec 10, 2003
9
0
0
US
I need to disable some controls on a form for certain users of my database and I'm having trouble accomplishing this. I've been trying to use "Berlinda B Eras" steps on how to do it but her instructions are vague. Anyone know how to accomplish disabling controls based on user security? Or where to look to find the answer?
Thanks.
 
dhanson:

The process I use entails a User table that contains each user's network logon (CurrentUser) and a security level.

In the form's On_Open event, I use a DLookup to get the security level and then enable/disable the controls (usually just command buttons) as necessary.

Is this what you're looking for?
Larry De Laruelle
larry1de@yahoo.com

 
Start with the controls you wish to be user security controlled, have them start invisible (visible = no under properties). Then when the form is opened ("on open" event for the form), validate the user's security. I am assuming you have a table or list of the users that have security clearance. If you have the table of usernames, you can use the following:

If DCount("[name]", "userTable", "[name] = '" & Environ("username") & "'") > 0 Then
'set controls visible here
End If

What that does is count the number of times the user's name occurs in the table. If you point it to the table containing the list of cleared employees, then if the employee's username occurs in the table, the count will be greater than zero and the controls get set to visible. Otherwise the controls remain invisible. (you may want to have an else statement here just to make sure)

If you have just a static list of users who have clearance, you can always use a "select case" statement. Again, get the username from the Environ function and compare to the list.

Hopefully that helps some.

Crater
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top