3 Replies Latest reply on Nov 9, 2018 4:24 PM by Fiannax

    Assign multistate to a Commandbutton in VBA

    Fiannax

      Hi,

      I have a server with different Processbook displays on it, every user in the company have access to these displays. Every display has different Commandbuttons that change colour\"shape" when pressed, but only the user who makes the change (user1) can see the actual state of the button because it doesn't apply till user1 saves the display, user2 can't see the button updating in real time so I'd like to know if is possible to assign a multistate to a commandbutton with VBA or if you have any suggestion. I tried with a simple rectangle but it loses the Caption property that I use to store the tagname.

       

      Regards

        • Re: Assign multistate to a Commandbutton in VBA
          Eugene Lee

          As the CommandButton doesn't derive from the Symbol class, it doesn't have multistate support. You can use the Text Symbol instead.

           

          It has the support that you need such as the Click event, the Contents property for storing your tag name, it has multistate support. You can also overlay a Rectangle on it to make it look more like a 'button'.

          2 of 2 people found this helpful
            • Re: Assign multistate to a Commandbutton in VBA
              Asle Frantzen

              Through different projects I've experienced that using the Text symbol as button isn't a perfect solution, as users would have to "aim" for the actual text lines. Especially when using larger fonts it's annoying that if you press in the middle of the letter U or O nothing happens. The solution we've used is to create a rectangle with No Fill and place that above the text, and use the button_click event for that instead. You can add a gray border so it resembles a button, that makes it much more intuitive for the end user.

              2 of 2 people found this helpful
                • Re: Assign multistate to a Commandbutton in VBA
                  Fiannax

                  Thanks for the suggestions. I'd like to share the solution that worked for me:

                  I noticed that I had another object (a polyline) that supports multistate and so I linked the multistate to the polyline (es. purple when the tag is "1" and none (no colour) when is "0") but you can do the same with a text or rectangle as well. Then with VBA:

                   

                  Private Sub overw1_StateChanged(bCancelDefault As Boolean)      'overw is the name of the polyline

                  If overw1.GetMultiState.CurrentState = 1 Then

                  CommandButton1.BackColor = vbRed      'the commandbutton becomes red when the value of the tag is 1 (multistate state = 2)

                  Else

                  If overw1.GetMultiState.CurrentState = 0 Then

                  CommandButton1.BackColor = vbGreen      'the commandbutton becomes green when the value of the tag is 0 (multistate state = 1)

                  End If

                  End If

                  End Sub

                   

                  Hope this helps!