Results 1 to 6 of 6
  1. #1
    Delfina is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Location
    Bartlesville OK
    Posts
    47

    Hide command button on form from certain users


    Could you please tell me why the hide command buttons code is not working. It works in the my database named sample database, but not this one. I want to use one menu and hide certain buttons from certain users. I am trying in in 2007 and 2016.
    Attached Files Attached Files

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Well that looks familiar!

    The code doesn't know what the AccessLevel is for the logged in user

    Suggest you add a function GetAccessLevel in a standard module.
    Use a DLookup to get the value for the logged in user

    Then change the code on your form to reference the function

    EDIT: As I'm now at my computer I looked at it properly
    As well as the above comments (now done), you cannot hide a control that has the focus
    So I've added a Close button to that form and set focus to that when the form loads

    The modified code now shows/hides the button correctly
    Attached Files Attached Files
    Last edited by isladogs; 02-16-2019 at 06:17 PM. Reason: More info & attached file
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Delfina is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Location
    Bartlesville OK
    Posts
    47
    I know that I have only been working on this for a few hours, but it seems like a week. I can't figure it out. I have attached the one the have been working on.
    Attached Files Attached Files

  4. #4
    Delfina is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Location
    Bartlesville OK
    Posts
    47
    I have really been stressing about this. But I think I understand now. Please correct me if I am wrong.
    I was trying to log in as another user to test and see how it works for each button. But the code that you added actually makes the command buttons visible or invisible according to the computer login. So if I log in on my computer it shows certain buttons as to where if I logged in on Kyle's or Amber's computer it would show different buttons according to the access level. I hope I am understanding this correctly. That would be really awesome.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Did you see what I posted in an edit to the previous reply.
    It was before you posted but not by much....
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    Delfina is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Jan 2019
    Location
    Bartlesville OK
    Posts
    47
    I can't tell you how much I appreciate all your help. I am feeling more secure about doing this database all the time. I have the ability to make tables, queries, forms and reports to do most of what I want to do in a database. But I did not know anything about security. And when it comes to code, I have no knowledge. It is like a foreign language. However I am learning bits and pieces.

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

Similar Threads

  1. Hide command button on form from certain users
    By Delfina in forum Programming
    Replies: 9
    Last Post: 02-09-2019, 07:36 PM
  2. Replies: 1
    Last Post: 10-27-2016, 10:51 PM
  3. Hide Button in sub form view
    By Derrick T. Davidson in forum Programming
    Replies: 5
    Last Post: 01-27-2016, 07:13 AM
  4. Replies: 2
    Last Post: 06-06-2012, 10:53 AM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 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