Restricting Command Button Usage for Certain Users

M

Ms-Exl-Learner

Hi All,

I have assigned user level security for my access database and I am having a
Form which will Open at Startup, the Startup form is having two command
buttons I just want to set one of the command button should be accessed by
only 4 persons and the rest of the 100 users should not able to click that.
I just want to disable the Command button for that 100 Users and only the 4
persons can able to access it. Please guide me how I can do that and if
possible please redirect me to any web URL where the step by step method is
available.

Thanking you,
 
T

Tom van Stiphout

On Sun, 21 Mar 2010 16:10:34 +0530, "Ms-Exl-Learner" <[email protected]>
wrote:

We'll assume you correctly applied ULS, per the Access Security FAQ
from microsoft.com.
If you then want to test for four persons, you can write code like
this:
dim aryHasAccess as variant
dim varUser as variant
dim blnHasAccess as boolean
aryHasAccess = Array("user1", "user5", "user9", "user36")
for each varUser in aryHasAccess
if varUser = CurrentUser then
blnHasAccess = True
exit for
end if
next
Me.myButton.Enabled = blnHasAccess

Consider adding these people to a group; then you can test for group
membership (via DAO.Groups and DAO.User).

I am assuming this button opens a form or report. It is much better
putting this code in the Form_Open or Report_Open event. Why? Because
over time there may be several ways to open your form, and you may
forget to disable the buttons everywhere. Or the user opens the form
directly from the object list. If you put it in the Open event, you
have to write code only once. Replace the last line of my code with:
Cancel = not blnHasAccess

-Tom.
Microsoft Access MVP
 
S

Song

Hi All,

I have assigned user level security for my access database and I am having a
Form which will Open at Startup, the Startup form is having two command
buttons I just want to set one of the command button should be accessed by
only 4 persons and the rest of the 100 users should not able to click that.
I just want to disable the Command button for that 100 Users and only the4
persons can able to access it.  Please guide me how I can do that and if
possible please redirect me to any web URL where the step by step method is
available.

Thanking you,

I use a small table to contain power user ID. At form open event, I
use dlookup to see if network login user is available in power user
table. If it is, enable button. Otherwise disable button. To get
network userID, see http://www.mvps.org/access/api/api0008.htm

Song
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top