switchboard buttons...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jayme
    New Member
    • Mar 2007
    • 83

    switchboard buttons...

    I have a db that will be on the network for several people to access..Is there a way to lock certain buttons on the switchboard so that only the admins can have access to them-whereas when the "users" open the db either the buttons aren't there or they are unable to click on them.
    Any ideas?
    Thank you!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    In the on load event of the form you can check their status, "user" or "admin" and if they're "admin" then disable or make the buttons invisible.

    Here's some pseudocode:
    Code:
    Private Sub Form_Load()
       If User = "Admin" Then
          but_Name.Visible = False
       End If
    End Sub

    Comment

    • Denburt
      Recognized Expert Top Contributor
      • Mar 2007
      • 1356

      #3
      If your database has security setup for User and group permissions then Rabbits idea is best however if you do not then you could use the following, depending on the operating system. I don't think win95,Me,or 98 supports this however it should work when Windows security or AD (active directory) is in place and controlling passwords:

      Code:
      Private Sub Form_Load()
         If Environ("USERNAME")= "Jayme" Then
            but_Name.Visible = False
         End If
      End Sub

      Comment

      • jayme
        New Member
        • Mar 2007
        • 83

        #4
        the button i am trying to lock/hide opens up another switchboard - would this code still work for that? i've been trying to get it to work for that but am not sure if i am on the right track...theres really only one button i want to do this with on the default switchboard. so i wasnt sure how to specify just to hide that button and all the switchboards under that one-or connected to that certain button.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by jayme
          I have a db that will be on the network for several people to access..Is there a way to lock certain buttons on the switchboard so that only the admins can have access to them-whereas when the "users" open the db either the buttons aren't there or they are unable to click on them.
          Any ideas?
          Thank you!
          The only way you can do this is to extract a combination of the UserName and Switchboard Name, not the UserName alone. Because a Switchboard is basically a single Form which is dynamically generated, you must test for 'both' conditions since Button #3 on 1 Switchboard should be accessible to an average User whereas the exact Button on another may not be. If you are interested, let me know and I'll show you where and how to generate the code.

          Comment

          • jayme
            New Member
            • Mar 2007
            • 83

            #6
            Originally posted by ADezii
            The only way you can do this is to extract a combination of the UserName and Switchboard Name, not the UserName alone. Because a Switchboard is basically a single Form which is dynamically generated, you must test for 'both' conditions since Button #3 on 1 Switchboard should be accessible to an average User whereas the exact Button on another may not be. If you are interested, let me know and I'll show you where and how to generate the code.
            that sounds like what i need. basically i have 4 buttons on the default switchboard of which one should only be accessible to admins. so that is the only button that i need locked or hidden when a "user" logs in.
            i would appreciate your help! thanks!!

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by jayme
              that sounds like what i need. basically i have 4 buttons on the default switchboard of which one should only be accessible to admins. so that is the only button that i need locked or hidden when a "user" logs in.
              i would appreciate your help! thanks!!
              I apologize for reading too much into your question. If the above is all you need, simply place this code in the Switchboard's Open() Event:
              Code:
              Select Case CurrentUser
                Case "Admin"
                  Me![Option3].Enabled = True
                Case "User"
                  Me![Option3].Enabled = False
                Case Else
                  Me![Option3].Enabled = False
              End Select

              Comment

              • jayme
                New Member
                • Mar 2007
                • 83

                #8
                no thats fine..i had no idea! :-) thanks so much for your help. that works perfectly! thank you so much!!

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #9
                  Originally posted by jayme
                  no thats fine..i had no idea! :-) thanks so much for your help. that works perfectly! thank you so much!!
                  You're welcome.

                  Comment

                  Working...