Results 1 to 5 of 5
  1. #1
    CompostKid is offline Novice
    Windows Vista Access 2003
    Join Date
    Jul 2010
    Posts
    3

    Removing bound property of combo box for certain users

    Hi, I've got a timesheet database with user level security set up. To stop the multiple users being able to see other peoples records within the database, I've bound the control source of the name combo box to =CurrentUser().



    This is where the question comes. For some users (the managers) I don't want the box to be bound so they can select other users for review purposes. I think I need an If statement in here but am a complete programming novice.

    Does anyone know what code (if its possible) I should put behind the control to make this possible.....

    Many thanks

    Dave

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Create a copy of the Combo Box that's not bound. Then, On Form Load, just switch the visibility of the two Combo Boxes based on the User's Group. . .

    The other option is to actually have two separate Forms: One where the Combo Box is locked to the user and one where it isn't. Then, on Form Open, you can have an IF statement that switches Forms (closes one and opens the other) based on the User's Group.

    If you're using UAC, here's a simple Function to check if a certain user is a member of a certain Group:

    Code:
    Private Function MemberOf(strGroupName As String, strUserName As String) As Boolean
      Dim user As DAO.user
      Dim work As DAO.Workspace
    
      On Error Resume Next
    
      Set work = DBEngine.Workspaces(0)
      Set user = work.Groups(strGroupName).Users(strUserName)
    
      MemberOf = Err.Number <> 3265
    End Function
    With the above function, the following Code would return True if the user Rawb was a member of the Admins Group:
    Code:
    MemberOf("Admins", "Rawb")

  3. #3
    CompostKid is offline Novice
    Windows Vista Access 2003
    Join Date
    Jul 2010
    Posts
    3
    Hi Rawb,

    Thanks for your help on this. I've put the code into the "on Open" event for the form however it keeps coming up with the error message "Ambiguous Name Detected: MemberOf"

    Any ideas?

    Many thanks,

    Dave

  4. #4
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    The "Ambiguous Name Detected" error means that you're declaring the same variable (in this case MemberOf) in two different places. Because of this, Access doesn't know which MemberOf variable you're trying to use.

    Most likely, one instance of the variable is declared Publically via a Module (or at the top of your Form's VBA Code), and another one was declared inside your Function. However, it's also possible that both instances are Publically declared variables from a Module, etc. (this happened to me once!).

  5. #5
    CompostKid is offline Novice
    Windows Vista Access 2003
    Join Date
    Jul 2010
    Posts
    3
    Thanks Rawb, I've had a play around with it and I think the easiest way will be to create two slightly different front ends - one with the box locked for the emplyees and one unlocked for the managers.

    Now for the joys of splitting....

    Thanks for your help

    Dave

Please reply to this thread with any new information or opinions.

Similar Threads

  1. removing security from not my own database
    By zomas in forum Security
    Replies: 1
    Last Post: 08-01-2010, 10:43 PM
  2. Removing all letters or all numbers from string
    By Hayley_sql in forum Programming
    Replies: 2
    Last Post: 09-16-2009, 02:01 AM
  3. Replies: 10
    Last Post: 08-01-2009, 06:48 AM
  4. Removing the delete prompt.
    By botts121 in forum Programming
    Replies: 4
    Last Post: 06-26-2009, 11:45 AM
  5. removing record from form
    By rsearing in forum Programming
    Replies: 7
    Last Post: 05-14-2009, 10:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums