Hiding fields based on user ID

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wideasleep
    New Member
    • May 2007
    • 72

    Hiding fields based on user ID

    Hello everyone,

    I am trying to make fields on a form hidden based on a user ID. I'm pretty much starting this right from scratch. Can anyone point me in the right direction on how this can be done?

    OS: Vista
    Version: 2007

    Thanks
  • lee123
    Contributor
    • Feb 2007
    • 556

    #2
    hey wideasleep, well first of all lets start by asking what fields are you trying to hide because you really didn't leave much to go on.

    lee123

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      Are you thinking of a security feature where certain controls are only visible to a particular set of users?

      Comment

      • wideasleep
        New Member
        • May 2007
        • 72

        #4
        Originally posted by lee123
        hey wideasleep, well first of all lets start by asking what fields are you trying to hide because you really didn't leave much to go on.

        lee123
        The fields are going to vary from combo boxes to text boxes.

        Comment

        • wideasleep
          New Member
          • May 2007
          • 72

          #5
          Originally posted by NeoPa
          Are you thinking of a security feature where certain controls are only visible to a particular set of users?
          Exactly! This is a work order system for our maintenance department. One part will be for users to submit a work order. This information is in it's own table. The other user will be for our maintenance dept. This will be for assigning work orders to the maintenance staff and for them to fill out that information once they have completed the work. And then the final part will be for our maintenance manager to complete his part of it.

          The first part I already have put together for users and that is setup for no edits. In fact it has to be. I was thinking that the other sections might have to be subforms so the rest can be edited by the maintenance staff.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            In that case I would start off with a list of names (in a string variable on constant). These would be separated by a character unlikely to be found in a name. EG ";". Make sure to have one at the start AND the end of the list though. A typical list might look like ";Bob;Andrew;wi deasleep;Sarah; Melissa;".
            When you open the form you get the current username (using Environ("UserNa me") or whatever - there are various methods); put it in a string surrounded by the separator character (";wideasleep;" ) then use InsStr() to determine if that name is found in the list or not. Assuming the list is for those names who CAN see the controls, simply set the control.Visible property to the return value of the InStr() call. Alternatively you can set it to (InStr(blah blah) > 0).
            This should do what you need. Let us know how you get on with it :)

            Comment

            • wideasleep
              New Member
              • May 2007
              • 72

              #7
              Originally posted by NeoPa
              In that case I would start off with a list of names (in a string variable on constant). These would be separated by a character unlikely to be found in a name. EG ";". Make sure to have one at the start AND the end of the list though. A typical list might look like ";Bob;Andrew;wi deasleep;Sarah; Melissa;".
              When you open the form you get the current username (using Environ("UserNa me") or whatever - there are various methods); put it in a string surrounded by the separator character (";wideasleep;" ) then use InsStr() to determine if that name is found in the list or not. Assuming the list is for those names who CAN see the controls, simply set the control.Visible property to the return value of the InStr() call. Alternatively you can set it to (InStr(blah blah) > 0).
              This should do what you need. Let us know how you get on with it :)
              Will give that a try if I understand it right. Thanks

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                No problem.
                Come back with questions if you need more help or better understanding :)

                Comment

                Working...