chage message when user doesn't have access to a menu

G

Guest

Hi. In my database I create a login system from the access o+ption
Tools»Security» user level security.

Everythings is working fine, but I would like know if it's possible to
change the error message that appears when a user doesn't have access to a
specific form or option. Because users here don't understand English not even
the techinicion error messages.

Regards,
Marco
 
G

Guest

It's better to disable a button if the user doesn't have permission. This way
they will never get an error message. To check the user's permission, use
this module:

Function IsUserMemberOfGroup(strUser As String, strGroup As String) As Integer
' Comments : Determines if the named user is a member of the specified
group
' Parameters: strWorkspace - name of the workspace to use or "" (blank
string) for Workspaces(0)
' strUser - name of the user to check
' strGroup - group to check membership in'
' Returns : True-user is a member of group, false otherwise
'
Dim varTemp As Variant
Dim wrkTemp As Workspace
On Error Resume Next

Set wrkTemp = DBEngine.CreateWorkspace("NewWS", "AdminUserName",
"AdminPassword")
On Error Resume Next
varTemp = wrkTemp.Users(strUser).Groups(strGroup).name
IsUserMemberOfGroup = (Err = 0)
wrkTemp.Close
End Function

In the OnOpen of the form, you would put:
Me.cmdMyButton.Enabled = IsUserMemberOfGroup(CurrentUser(), "Admin") 'or
whatever group you want to have access to this button.

Barry
 
G

Guest

Hi Barry, thanks for the reply.

Thats a good idea, but I've got 3 types of user, admins; Nota_Prod;
Prod_Acabado.

Adminis are admins, permission for everything. Nota_Prod, have permissions
for some buttons but not for others and the same for Prod_Acabado.

Do you think the idea of module is the best? Because I was thought, and when
about I creat a new group? That means that I have to reprogram the whole
stuff again?

Regards,
Marco
 
G

Guest

Marco Silva said:
Hi Barry, thanks for the reply.

Thats a good idea, but I've got 3 types of user, admins; Nota_Prod;
Prod_Acabado.

Adminis are admins, permission for everything. Nota_Prod, have permissions
for some buttons but not for others and the same for Prod_Acabado.

You can still use this for multiple groups. You'd just need to evaluate each
group.
Do you think the idea of module is the best? Because I was thought, and when
about I creat a new group? That means that I have to reprogram the whole
stuff again?

You usually wouldn't be adding new groups too often. However, this would be
the only way to intercept/prevent the standard message.

By the way, isn't there a version of Access available in your language?

Barry
 
G

Guest

Ok, I'll follow you suggestion.

Could you please discrimite a little more what I've got to do? What steps
should I do?

Marco
 
G

Guest

Paste the function I gave you into a module. Then, in each form's OnOpen
event, you call the code to enable/disable buttons or controls. For example,
if your form has a button called cmdEditRecord and you only want Admins and
Nota_Prod members to be able to click it, you'd do something like this:

Dim blnEnable As Boolean
blnEnable = IsUserMemberOfGroup(CurrentUser(), "Adminis") Or
IsUserMemberOfGroup(CurrentUser(), "Nota_Prod")
Me.cmdEditRecord.Enabled=blnEnable

Barry
 
G

Guest

I forgot to mention that, since you'll be hard coding your user name and
password in the IsUserMemberOfGroup function, you should password protect
your VBA project. This isn't the most secure method available, but it will
prevent the casual user from getting your password.

Barry
 

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