Tags: access, database, environment, microsoft, multiuser, mysql, objects, oracle, restrict, specific, sql, users
how can i restrict some objects from some users
On Database » Microsoft Access
6,169 words with 14 Comments; publish: Sun, 02 Dec 2007 16:00:00 GMT; (25078.13, « »)
i have a database in multiuser environment. i want to restrict some objects from some specific users. i've already set up different users security level. and if i use Tools-->Security-->User and Group Permission-->Permissions. it shows all the permissions the user have explicitly on the specific object. how do i revoke some of the permissions on specific object from specific user? should i check those permissions? but it doesnt work.
anybody has any suggestions?
Thanks
Anwar
http://ms-access.itags.org/q_ms-access-database_88776.html
All Comments
Leave a comment...
- 14 Comments

- Do you mean forms etc or text boxes etc.
You can use the currentuser() to return what ever they logged in as.
E.g. If currectuser() <> "UserNameX" then me.CommandButton1.visible = false
If you mean forms etc. then it's a lot more tricky. You can hide then in the db window but this will get very complicated.
#1; Tue, 11 Dec 2007 19:37:00 GMT

- yes, i mean forms, tables, reports etc. i tried to hide tables or forms. but i hides from all the user. i want hide from specific users not from all the users.
thanks
Anwar
#2; Tue, 11 Dec 2007 19:38:00 GMT

- The least complicated way of controlling access on the level of forms and reports for large groupings is to make specific application DBs. i.e. Sales, Customer Service, Processing, S&H.#3; Tue, 11 Dec 2007 19:39:00 GMT

- OR you could try this...
While opening that perticular form, check the currentuser(). Use if condition. If the currecntuser() = "<allowed user/s> open the form. I think this is the easiest way per me... Good Luck...
Sandeep
#4; Tue, 11 Dec 2007 19:40:00 GMT

- thanks Sandeep,
that is very helpful. it worked on Form but its not working on Report
If CurrentUser = "mdaislam" Then
DoCmd.OpenReport "Payment Receipt"
ElseIf CurrentUser = "ray" Then
DoCmd.OpenReport "Payment Receipt"
ElseIf CurrentUser = "kmurphy" Then
DoCmd.OpenReport "Payment Receipt"
Else
DoCmd.Close
MsgBox "I am sorry! You don't have access to this Report"
End If
did i write the code right way? problem is showing on DoCmd line. anybody can help me pls?
Thanks
Anwar
#5; Tue, 11 Dec 2007 19:41:00 GMT

- I think the way it shows here, did you foget to put "()" after "currentuser"? Just checking...
Sandeep
#6; Tue, 11 Dec 2007 19:42:00 GMT

- [QUOTE][SIZE=1]=== Original Words ===
mdaislam
thanks Sandeep,
that is very helpful. it worked on Form but its not working on Report
If CurrentUser = "mdaislam" Then
DoCmd.OpenReport "Payment Receipt"
ElseIf CurrentUser = "ray" Then
DoCmd.OpenReport "Payment Receipt"
ElseIf CurrentUser = "kmurphy" Then
DoCmd.OpenReport "Payment Receipt"
Else
DoCmd.Close
MsgBox "I am sorry! You don't have access to this Report"
End If
did i write the code right way? problem is showing on DoCmd line. anybody can help me pls?
Thanks
--------------------------
Hi, Try this:
If CurrentUser() = "mdaislam" or CurrentUser() = "ray" or CurrentUser() = "kmurphy" then
DoCmd.OpenReport "Payment Receipt"
else
MsgBox "I am sorry! You don't have access to this Report"
end if
Sandeep
--------------------------
#7; Tue, 11 Dec 2007 19:43:00 GMT

- hi Sandeep,
it was a real quick reply. i just posted this problem. thanks for reply. but i tried on that way. but still its not working. it is showing problem on DoCmd line.
If CurrentUser() = "mdaislam" Or CurrentUser() = "ray" Or CurrentUser() = "kmurphy" Then
DoCmd.OpenReport "Payment Receipt"
Else
MsgBox "I am sorry! You don't have access to this Report"
End If
thanks
Anwar
#8; Tue, 11 Dec 2007 19:44:00 GMT

- oh no. i am sorry. its showing problem on private sub Report_Open line.
Private Sub Report_Open(Cancel As Integer)
If CurrentUser() = "mdaislam" Or CurrentUser() = "ray" Or CurrentUser() = "kmurphy" Then
DoCmd.OpenReport "Payment Receipt"
Else
MsgBox "I am sorry! You don't have access to this Report"
End If
End Sub
#9; Tue, 11 Dec 2007 19:45:00 GMT

- What error do you get? I think it would be a good idea to remove space from your report name. You could rename it and also change the report name in your code while opening it. I think that should work...
Good Luck...
Sandeep
#10; Tue, 11 Dec 2007 19:46:00 GMT

- hi Sandeep,
i am sorry. i am bothering u. i changed the report name. now it says the message "i am sorry! you dont have access to this report". but right after that it opens the report. i think we have right some code after "else" and before the message command so that it can restrict to open the report. i tried DoCmd.Close. but i dont think its logical because the report didnt open yet. how can it close. any other command do u know?
thanks
Anwar
#11; Tue, 11 Dec 2007 19:47:00 GMT

- Since the report is in the process of opening, you don't need to call DoCmd.OpenReport if the user HAS permission. You only need to cancel the open event if the user does NOT have permission. Try it this way:
Private Sub Report_Open(Cancel As Integer)
Select Case CurrentUser()
Case "mdaislam", "ray", "kmurphy"
' do nothing
Case Else
MsgBox "I am sorry! You don't have access to this Report"
Cancel = True
End Select
End Sub
Hope that helps :)
#12; Tue, 11 Dec 2007 19:48:00 GMT

- thank Sandeep and JTRockville
i am done with my problems. your help is really appreciable
Anwar
#13; Tue, 11 Dec 2007 19:49:00 GMT

- === Original Words ===
Robt917
The least complicated way of controlling access on the level of forms and reports for large groupings is to make specific application DBs. i.e. Sales, Customer Service, Processing, S&H.
Two good ways to do this are:
depending on the version you can download the secutity wizard from Microsoft's http://support.microsoft.com or using the security features in microsft do not permit user or groups from having access to forms, queries, tables, etc. But remember Access enforces the LEAST restrictive rights in security where NT, Novell , etc enforces the MOST restirctive
or try this - on the on open event of the form evaluate the user and if the criteria is not met - close the form.
#14; Tue, 11 Dec 2007 19:50:00 GMT