Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Forms,

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-07-25 : 06:06:02
Hi i've got about 4 forms and on each form i've got commands buttons that peform certain actions, i would only like certain people to be able to access these buttons, so what am looking for is a way of enabling or disabling the buttons on the form, when they log in, is this possible in access. I see there is a security options would they peform this for me ?

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-08-10 : 11:18:56
you could create a public variable in a module eg: strUser in PublicVars

Once your user logs in set strUser = userName.text

Once they click the command button in question you could then say

If strUser = "yourName" Then
DO IT
Else
msgbox("You do not have permission!")

hth

Pace


when life hands you lemons, ask for tequila and salt
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-08-10 : 11:20:11
oooops...

What you might want to do is say

If strUser = "yourName" Then me.cmdYourButton.Visible = True
else me.cmdYourButton.Visible = False

Edit: alternatively set the property Visible to false at design time, then on the Form_Open Event do the above... which would set the button appropraitely at runtime.

when life hands you lemons, ask for tequila and salt
Go to Top of Page
   

- Advertisement -