Results 1 to 15 of 15
  1. #1
    Join Date
    Oct 2002
    Posts
    33

    Unanswered: how can i restrict some objects from some users

    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

  2. #2
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168
    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.

  3. #3
    Join Date
    Oct 2002
    Posts
    33
    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

  4. #4
    Join Date
    Apr 2003
    Location
    Santa Barbara, CA
    Posts
    67
    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.

  5. #5
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50
    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

  6. #6
    Join Date
    Oct 2002
    Posts
    33
    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

  7. #7
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50
    I think the way it shows here, did you foget to put "()" after "currentuser"? Just checking...
    Sandeep

  8. #8
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50
    [QUOTE][SIZE=1]Originally posted by 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
    -----------------------------------------------------------------------------------

  9. #9
    Join Date
    Oct 2002
    Posts
    33
    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

  10. #10
    Join Date
    Oct 2002
    Posts
    33
    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

  11. #11
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50
    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

  12. #12
    Join Date
    Oct 2002
    Posts
    33
    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

  13. #13
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    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:
    Code:
    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

  14. #14
    Join Date
    Oct 2002
    Posts
    33
    thank Sandeep and JTRockville

    i am done with my problems. your help is really appreciable

    Anwar

  15. #15
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    Originally posted by 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •