Enabling/Disabling controls based on User Security

        5 votes: *****     7,821 views      No comments
by Allen Browne, 20 April 2005    (for ALL VERSIONS of Access)

MS-Access Tips for Serious Users

Provided by berlinda b eras, 14-Nov-95.


Enabling/Disabling controls, based on User Security

In conjunction with using security work groups to limit/permit functionality to individual users, controls may be enabled/ disabled at run time. Otherwise users will have to view a warning message box from Access, when they try to do something they're not allowed to do.

Note that the permission assignments for workgroups are by table, query, form, macro, etc. So this type of routine must be used to 'set - permissions' for individual controls. As in the example below, "viewers" must have permission to see the mainswitch board form, but it is necessary to disable buttons on that form.

To do this:

  • create a table with username (key) and workgroup
  • create a usersform (autoform is good enough) based on table
  • open form in autoexe (hidden) to where condition [username]=CurrentUser()
  • set values of controls with On Open property based on usergroup.

For example:

  • If mainswtich board form has buttons to add, edit and report on records,you may set up a workgroup of accounts that may only report, called viewers.
  • To disable the add and edit buttons use the OnOpen property of the mainswtich board form to run the following:
    if condition:	[Forms]![usersform]![workgroup]="viewers"
    
    setvalue:	[Forms]![mainswitch]![reportsbutton].[Enabled] Yes
    		[Forms]![mainswitch]![addbutton].[Enabled] No
    		[Forms]![mainswitch]![editbutton].[Enabled] No

This will 'gray-out' and disable the add and edit buttons.


This tip was supplied by berlinda b eras, 14-Nov-95.

Home Index of tips Top

Rate this article:  Your rating: PoorYour rating: Not so goodYour rating: AverageYour rating: GoodYour rating: Excellent


This is a cached tutorial, reproduced with permission.

Have your say - comment on this article.

What did you think of 'Enabling/Disabling controls based on User Security'?

No comments yet.

Why not be the first to comment on this article?!

Have your say...

Name
E-mail (e-mail address will be kept private)
Comments


Comments require approval before being displayed on this page (allow 24 hours).