53 Replies Latest reply on Aug 17, 2011 8:58 PM by dtakara

    How to copy code to multiple symbols in a display?

    pisupportduke

      Hello,

       

      I have everything worked out in the code for it to work for one object in the display. My problem is how to copy that code so every time I click on a different object a form specified for that object will display and then able to save that inputted information to that objects specific form. Here is my display:4401.q3.gif

       

      This is my coding window. I know how to add more forms but not more display objects. I require more display objects because my click event is within my symbol. This is my code for the symbol:

       
      Private Sub Aircompressor3_1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
          UserForm1.Show
      End Sub
      

       

       

      ___________________________________________________

       
      Sub store_value(Name As String, value As String)
          If ThisDisplay.NamedValues(Name) Is Nothing Then
          ThisDisplay.NamedValues.Add Name, value
       Else
           ThisDisplay.NamedValues(Name).value = value
       End If
      End Sub
      

       

       

      _____________________________________________

       
      Function get_value(Name As String) As String
          If Not ThisDisplay.NamedValues(Name) Is Nothing Then
          get_value = ThisDisplay.NamedValues(Name).value
       Else
          get_value = ""
        End If
      End Function
      

       

       

                     

       

      I would be okay if I could add multiple "this display" objects so in each "this display" I could change the symbol name.

       

      8078.q4.bmp

       

      Please dont hesitate if you have any questions.

       

      Thanks, Alex 

        • Re: How to copy code to multiple symbols in a display?
          dtakara

          Alex

          My problem is how to copy that code so every time I click on a different object a form specified for that object will display and then able to save that inputted information to that objects specific form.

           

          As an example, this is the code you would use to make UserForm2 to show upon the click event of the Aircompressor3_2 object:

           
          Private Sub Aircompressor3_2_Click(ByVal lvarX As Long, ByVal lvarY As Long)
              UserForm2.Show
          End Sub
          

           this is the code you would to make UserForm3 to show upon the click event of the Aircompressor3_3 object:

           
          Private Sub Aircompressor3_3_Click(ByVal lvarX As Long, ByVal lvarY As Long)
              UserForm3.Show
          End Sub
          

           and so on.

           

          Alex

          I require more display objects because my click event is within my symbol.

           


          If I undestand your situation correctly, I think it's actually no problem that the display object is the same. Actually, it must be the same, because you want the equipment symbols to be available and clickable from the same display, correct?

           

          You just need to use an appropriate naming convention for the items of the NamedValues collection of the display object. For example, you could name them like this:

          • "UserForm1-TextBox1-Value"
          • "UserForm1-TextBox2-Value"
          • "UserForm1-TextBox3-Value"
          • "UserForm2-TextBox1-Value"
          • "UserForm2-TextBox2-Value"
          • "UserForm2-TextBox3-Value"
          • "UserForm3-TextBox1-Value"
          • "UserForm3-TextBox2-Value"
          • "UserForm3-TextBox3-Value"

          By the way, have you considered writing the values of fields of your UserForms into PI tags, instead of keeping them in the NamedValues collection of your ProcessBook? This might be helpful, if you need to keep their history, and would also have the advantage of making them available to PI users in general and not only people who view your ProcessBook display.

           

          I hope this helps.

            • Re: How to copy code to multiple symbols in a display?
              pisupportduke

              Ah I see. Move my click event from my display to each form. Makes sense.

               

              I have not considered writing my values as PI tags. That seems like a great idea. Can you explain how writing a PI tag history will look? Will I be able to see all of the previous forms? Would this would give me the ability to go look back at a pi tag and see when the last problem to a piece of equipment was and what work was done  to it? Is my idea correct?

               

              -Alex

                • Re: How to copy code to multiple symbols in a display?
                  pisupportduke

                  Daniel,

                   

                  I moved my click event to my form as recommended but unfortunatly my form does not activate when I select my aircompressor. Here is my code for my form:

                   

                  'Click event to activate userform1
                  Private Sub Aircompressor3_1_Click(ByVal lvarX As Long, ByVal lvary As Long)
                      UserForm1.Show
                  
                  End Sub
                  
                  'save button
                  Private Sub CommandButton1_Click()
                      ThisDisplay.store_value "Texto1", UserForm1.TextBox1.Text
                      ThisDisplay.store_value "Texto2", UserForm1.TextBox2.Text
                      ThisDisplay.store_value "Texto3", UserForm1.TextBox3.Text
                      ThisDisplay.store_value "Texto4", UserForm1.TextBox4.Text
                      ThisDisplay.store_value "Texto5", UserForm1.TextBox5.Text
                      ThisDisplay.store_value "Name1", UserForm1.ComboBox1.Text
                      ThisDisplay.store_value "Green1", UserForm1.OptionButton1.value
                      ThisDisplay.store_value "Yellow1", UserForm1.OptionButton2.value
                      ThisDisplay.store_value "Red1", UserForm1.OptionButton3.value
                  End Sub
                  
                  'Saves the eqipment condition right before the form is closed
                  Private Sub UserForm_Terminate()
                      ThisDisplay.store_value "Green1", UserForm1.OptionButton1.value
                      ThisDisplay.store_value "Yellow1", UserForm1.OptionButton2.value
                      ThisDisplay.store_value "Red1", UserForm1.OptionButton3.value
                  End Sub
                  
                  'When form is opened it recalls all information that was stored
                  Private Sub UserForm_Activate()
                      UserForm1.TextBox1.Text = ThisDisplay.get_value("Texto1")
                      UserForm1.TextBox2.Text = ThisDisplay.get_value("Texto2")
                      UserForm1.TextBox3.Text = ThisDisplay.get_value("Texto3")
                      UserForm1.TextBox4.Text = ThisDisplay.get_value("Texto4")
                      UserForm1.TextBox5.Text = ThisDisplay.get_value("Texto5")
                      UserForm1.ComboBox1.Text = ThisDisplay.get_value("Name1")
                      UserForm1.OptionButton1.value = ThisDisplay.get_value("Green1")
                      UserForm1.OptionButton2.value = ThisDisplay.get_value("Yellow1")
                      UserForm1.OptionButton3.value = ThisDisplay.get_value("Red1")
                  
                      UserForm1.ComboBox1.AddItem " "
                      UserForm1.ComboBox1.AddItem "Glover, Aaron"
                      UserForm1.ComboBox1.AddItem "Hammond, Rick"
                      UserForm1.ComboBox1.AddItem "Meister, Brian"
                      UserForm1.ComboBox1.AddItem "Walker, John"
                  End Sub
                  'Sets the lines for single space in equipment performance in text box
                  Private Sub TextBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
                      If KeyCode = 6 Then
                      TextBox3.Text = TextBox3.Text & Chr(6)
                  End If
                  End Sub
                  'Sets the lines for single space in repair notes and history in text box
                  Private Sub TextBox4_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
                      If KeyCode = 6 Then
                      TextBox4.Text = TextBox3.Text & Chr(6)
                  End If
                  End Sub
                  'clear button
                  Private Sub CommandButton2_Click()
                      TextBox1.Text = ""
                      TextBox2.Text = ""
                      TextBox3.Text = ""
                      TextBox4.Text = ""
                      TextBox5.Text = ""
                      ComboBox1.Text = ""
                      
                  'saves all fields once cleared so they show empty once form is opened again
                      ThisDisplay.store_value "Texto1", UserForm1.TextBox1.Text
                      ThisDisplay.store_value "Texto2", UserForm1.TextBox2.Text
                      ThisDisplay.store_value "Texto3", UserForm1.TextBox3.Text
                      ThisDisplay.store_value "Texto4", UserForm1.TextBox4.Text
                      ThisDisplay.store_value "Texto5", UserForm1.TextBox5.Text
                      ThisDisplay.store_value "Name1", UserForm1.ComboBox1.Text
                      ThisDisplay.store_value "Green1", UserForm1.OptionButton1.value
                      ThisDisplay.store_value "Yellow1", UserForm1.OptionButton2.value
                      ThisDisplay.store_value "Red1", UserForm1.OptionButton3.value
                  End Sub
                  'Exit button
                  Private Sub CommandButton3_Click()
                      Unload Me
                  End Sub
                  'causes object to be filled green if selected
                  Private Sub OptionButton1_Click()
                      ThisDisplay.Aircompressor3_1.FillColor = vbGreen
                      ThisDisplay.Aircompressor3_1.FillStyle = pbTBSolid
                  End Sub
                  'causes object to be filled yellow if selected
                  Private Sub OptionButton2_Click()
                      ThisDisplay.Aircompressor3_1.FillColor = vbYellow
                      ThisDisplay.Aircompressor3_1.FillStyle = pbTBSolid
                  End Sub
                  'causes object to be filled red if selected
                  Private Sub OptionButton3_Click()
                      ThisDisplay.Aircompressor3_1.FillColor = vbRed
                      ThisDisplay.Aircompressor3_1.FillStyle = pbTBSolid
                  End Sub
                  

                   

                  And this is my code for my display:

                   

                  'Stores input information
                  Sub store_value(Name As String, value As String)
                      If ThisDisplay.NamedValues(Name) Is Nothing Then
                      ThisDisplay.NamedValues.Add Name, value
                   Else
                       ThisDisplay.NamedValues(Name).value = value
                   End If
                  End Sub
                  'Retrieves input information
                  Function get_value(Name As String) As String
                      If Not ThisDisplay.NamedValues(Name) Is Nothing Then
                      get_value = ThisDisplay.NamedValues(Name).value
                   Else
                      get_value = ""
                    End If
                  End Function
                  

                   

                  Any pointers on how to get my form to appear when having the click event on my form?

                   

                   

                   

                  -Alex
                               

                    • Re: How to copy code to multiple symbols in a display?

                      Can you give an overview of the overall task you are trying to accomplish?

                       

                      Re. "Would this would give me the ability to go look back at a pi tag and see when the last problem to a piece of equipment was and what work was done  to it? Is my idea correct?..."

                       

                      if you have a system such as Maximo or SAP which is already tracking the work done on an equipment, it may be worthwhile considering whether the PI Alert from the equipment can be propagated to Maximo. And then the Maximo workflow will take over, and you could look at presenting both PI and Maximo data in context for an equipment - see screen below.

                       

                      5270.PI-trend-and-Maximo-WO-in-context.png

                       

                       

                       

                      SharePoint screen showing combined operations and maintenance data for Asset 11430; motor winding temperature (PI data) and work history (Maximo data)

                       

                       

                        • Re: How to copy code to multiple symbols in a display?
                          pisupportduke

                          Yes we do have maximo. This is something we do not have already. Thank you for your suggestion I will see if management would like something like that.

                           

                          In the mean time having one display means that the information saved on the form1 will also be saved on form2. How can I save it in different locations so when I call aircompressor 2 form then information on form1 from aircompressor 1 does not appear.

                           

                          Thanks,

                           

                          Alex

                            • Re: How to copy code to multiple symbols in a display?
                              dtakara

                              Alex

                              Yes we do have maximo. This is something we do not have already. Thank you for your suggestion I will see if management would like something like that.

                               

                              This sounds very good, Alex. Such conversation will probably help ensure you are getting the maximum value from the applications involved, i.e. the PI System and Maximo.

                               

                              Alex

                              In the mean time having one display means that the information saved on the form1 will also be saved on form2. How can I save it in different locations so when I call aircompressor 2 form then information on form1 from aircompressor 1 does not appear.

                               

                              You will probably want to have a separate UserForm for each equipment. You can add as many UserForms as you want to your ProcessBook display and manipulate them separately.

                                • Re: How to copy code to multiple symbols in a display?
                                  pisupportduke

                                  Below is a screen shot of my window. As you can see I have 2 user forms there. I copied and pasted the same user forms to each. Then I used the same code besides changing the userform1 to userform2 where is appropriate. Then in my display I have click events for each air compressor. click aircompressor 1 show userform1. Click aircompressor 2 show userform2.

                                   

                                  6710.q6.gif

                                   

                                  It feels like when it goes through the store command it all stores in one location and just rewrites over the previous information which is what I want for each form but not rewriting over information from another form. You see what i'm saying? I labeled the two forms different. The good news is that the correct form pops up when called but all of the information is the same.

                                   

                                  Thanks,

                                   

                                  Alex

                                    • Re: How to copy code to multiple symbols in a display?
                                      dtakara

                                      Alex,

                                       

                                      Although the NamedValues collection of a ProcessBook display is unique, you need to make sure that some NamedValues are used only for UserForm1, other NamedValues are used only for UserForm2, yet other NamedValues are used only for UserForm3, etc.

                                       

                                      Are you taking this into account in your code? More specifically, on the events that:

                                      1. read the appropriate items from the NamedValues collection and populate the corresponding UserForm objects accordingly when the UserForm is opened?
                                      2. write the values of the objects of the UserForm to the appropriate items in the NamedValues collection when the UserForm is being closed?
                                        • Re: How to copy code to multiple symbols in a display?
                                          pisupportduke

                                          Yep that did the trick. I had the same name values. Looks like it won’t be as simple as copy and paste but still easy enough. I also wanted to answer your question on what the overview is since I overlooked your questions earlier.

                                           

                                          The concept of this is to see an overview of all major equipment in the plant and see what’s available/running, what has problems and needs to be fixed, and equipment that is out of service. When someone is looking at this they will be able to tell what equipment needs work and what that work entitles. This way nothing will be forgotten about.

                                           

                                          Thank you for all of your help.

                                            • Re: How to copy code to multiple symbols in a display?
                                              pisupportduke

                                              Daniel,

                                               

                                              I have been thinking I am working in a display right now which only I can view. Is it possible to have it so everyone else can view it? Possibly edit the forms too? If so would it be too much to ask to explain how about I would go of this?

                                               

                                              Thanks,

                                               

                                              Alex

                                                • Re: How to copy code to multiple symbols in a display?
                                                  dtakara

                                                  Alex

                                                  I have been thinking I am working in a display right now which only I can view. Is it possible to have it so everyone else can view it? Possibly edit the forms too? If so would it be too much to ask to explain how about I would go of this?

                                                   

                                                  You can put your ProcessBook display file on a network share with write permissions to yourself and other ProcessBook users that will edit the forms.

                                                      • Re: How to copy code to multiple symbols in a display?
                                                        pisupportduke

                                                        Daniel,

                                                         

                                                        After copying and pasting and changing each value it soon has became very tedious and I am only about 1/8th done. It looks like I am going to have about 200 forms or so. So my question is there an easy way to copy the code so the user form number changes along with the value of each stored object? Or is there no way around it?

                                                         

                                                        -Alex

                                                          • Re: How to copy code to multiple symbols in a display?
                                                            andreas

                                                            How about that - you create a string in your display:

                                                             
                                                            Public MySymbol As String
                                                            

                                                            in every selection change event you assign this string to a unique name (maybe the symbol name):

                                                             
                                                            Private Sub Display_SelectionChange()
                                                                If Me.SelectedSymbols.Count = 1 Then
                                                                    MySymbol = Me.SelectedSymbols(1).Name
                                                                    Call UserForm1.Show
                                                                End If
                                                            End Sub
                                                            

                                                             and in your UserForm1 you use it to prefix your named values, decide what to do, etc.:

                                                             
                                                            Private Sub UserForm_Activate()
                                                                MsgBox ThisDisplay.MySymbol
                                                            End Sub
                                                            

                                                             

                                                              • Re: How to copy code to multiple symbols in a display?
                                                                pisupportduke

                                                                Andreas,

                                                                 

                                                                I am not sure if I understand. The code you recommended will relieve me inputting the same code on each form and changing the symbol value and the form number correct. I just can't seem to connect them together yet. What I understand the second set of code you gave me will replace my code for the click event of the symbol activating the form correct?

                                                                 

                                                                Private Sub Aircompressor3_1_Click(ByVal lvarX As Long, ByVal lvarY As Long)

                                                                 

                                                                   UserForm1.Show

                                                                 

                                                                End Sub

                                                                 

                                                                Also how is the third set of code used?

                                                                 

                                                                Thanks,

                                                                 

                                                                Alex

                                                                  • Re: How to copy code to multiple symbols in a display?
                                                                    andreas

                                                                    Alex,

                                                                     

                                                                    the code I posted is supposed to show the same userform whatever symbol you select on the display and let that userform know what symbol was selected.

                                                                     

                                                                    The first line defines a string variable in the display that you can access from the user form

                                                                     

                                                                    The second set calls the user form when you click on one symbol (replacing all your click events per symbol)

                                                                     

                                                                    The third set just illustrates how to use the string in the user form. You will have to change your single user form to evaluate the MySymbol string and act accordingly.

                                                                     

                                                                    So what I am proposing is that you do not create a click event per symbol, rather than monitoring if someone clicks on a symbol - and within a single user form (instead of one user form per symbol) you decide what to do based on the symbol that is clicked.

                                                                      • Re: How to copy code to multiple symbols in a display?
                                                                        pisupportduke

                                                                        Will this still give me the ability to keep the information inputted into the aircompressor 1 form separate from the information inputted on the aircompressor 2 form?

                                                                          • Re: How to copy code to multiple symbols in a display?
                                                                            andreas

                                                                            You need to use that MySymbol string to construct your named value collection - than you can keep that separate.

                                                                              • Re: How to copy code to multiple symbols in a display?
                                                                                pisupportduke

                                                                                Okay so I do not need more than one userform? For named value collection you are meaning

                                                                                 

                                                                                   ThisDisplay.store_value "Texto1", UserForm1.TextBox1.Text

                                                                                 

                                                                                   ThisDisplay.store_value "Texto2", UserForm1.TextBox2.Text

                                                                                 

                                                                                   ThisDisplay.store_value "Texto3", UserForm1.TextBox3.Text

                                                                                 

                                                                                And make a list of all my items in "" ?

                                                                                  • Re: How to copy code to multiple symbols in a display?
                                                                                    dtakara

                                                                                    Alex

                                                                                    Okay so I do not need more than one userform?

                                                                                     

                                                                                     

                                                                                    Per Andreas' suggestion, yes, that's correct. 

                                                                                     

                                                                                    Alex

                                                                                    For named value collection you are meaning

                                                                                     

                                                                                       ThisDisplay.store_value "Texto1", UserForm1.TextBox1.Text

                                                                                     

                                                                                       ThisDisplay.store_value "Texto2", UserForm1.TextBox2.Text

                                                                                     

                                                                                       ThisDisplay.store_value "Texto3", UserForm1.TextBox3.Text

                                                                                     

                                                                                    Yes, the NamedValues collection belongs to the ProcessBook display, but you can manipulate them from events of the UserForm object (like UserForm_Activate or UserForm_Terminate), as you've been doing with the custom store_value and get_value Subs.

                                                                                     

                                                                                    Alex

                                                                                    And make a list of all my items in "" ?

                                                                                     

                                                                                     

                                                                                    Yes, you need to name the items of the NamedValues collection conveniently, so that you know which ones are related to equipment 1, which ones are related to equipment 2, etc.

                                                                                     

                                                                                    I hope this helps. Please let us know if you have further questions.

                                                                                      • Re: How to copy code to multiple symbols in a display?
                                                                                        pisupportduke

                                                                                        Okay it is becoming more clear but I am still not totally clear. So I need only one userform and on that form it is going to have all the named values example

                                                                                         

                                                                                        ThisDisplay.store_value "Texto1-1", UserForm1.TextBox1.Text

                                                                                         

                                                                                        ThisDisplay.store_value "Texto1-2", UserForm1.TextBox1.Text

                                                                                         

                                                                                        ThisDisplay.store_value "Texto1-3", UserForm1.TextBox1.Text

                                                                                         

                                                                                        ThisDisplay.store_value "Texto1-4", UserForm1.TextBox1.Text

                                                                                         

                                                                                        ........  

                                                                                         

                                                                                        ThisDisplay.store_value "Texto1-134", UserForm1.TextBox1.Text

                                                                                         

                                                                                        Since i have 134 symbols I need to name 134 different store values correct?

                                                                                         

                                                                                        I thank you gentleman for your patience.

                                                                                         

                                                                                        -Alex

                                                                                          • Re: How to copy code to multiple symbols in a display?
                                                                                            pisupportduke

                                                                                            Here is my code for the userform, with the message box in it now. The point of showing you my code is so I can visually understand what is going on. Basically the new code you are suggesting will eliminate me from changing all of the teal colored text but is does not eliminate the need to change the red colored text. I will have to change the name value in each just as shown in my last post. Is this correct?

                                                                                             

                                                                                            'save button
                                                                                            Private Sub CommandButton1_Click()
                                                                                                ThisDisplay.store_value "Texto1", UserForm1.TextBox1.Text
                                                                                                ThisDisplay.store_value "Texto2", UserForm1.TextBox2.Text
                                                                                                ThisDisplay.store_value "Texto3", UserForm1.TextBox3.Text
                                                                                                ThisDisplay.store_value "Texto4", UserForm1.TextBox4.Text
                                                                                                ThisDisplay.store_value "Texto5", UserForm1.TextBox5.Text
                                                                                                ThisDisplay.store_value "Name1", UserForm1.ComboBox1.Text
                                                                                                ThisDisplay.store_value "Green1", UserForm1.OptionButton1.value
                                                                                                ThisDisplay.store_value "Yellow1", UserForm1.OptionButton2.value
                                                                                                ThisDisplay.store_value "Red1", UserForm1.OptionButton3.value
                                                                                            End Sub

                                                                                             

                                                                                             

                                                                                             

                                                                                            'Saves the eqipment condition right before the form is closed
                                                                                            Private Sub UserForm_Terminate()
                                                                                                ThisDisplay.store_value "Green1", UserForm1.OptionButton1.value
                                                                                                ThisDisplay.store_value "Yellow1", UserForm1.OptionButton2.value
                                                                                                ThisDisplay.store_value "Red1", UserForm1.OptionButton3.value
                                                                                            End Sub

                                                                                             

                                                                                            'When form is opened it recalls all information that was stored
                                                                                            Private Sub UserForm_Activate()
                                                                                                MsgBox ThisDisplay.MySymbol

                                                                                             


                                                                                                UserForm1.TextBox1.Text = ThisDisplay.get_value("Texto1")
                                                                                                UserForm1.TextBox2.Text = ThisDisplay.get_value("Texto2")
                                                                                                UserForm1.TextBox3.Text = ThisDisplay.get_value("Texto3")
                                                                                                UserForm1.TextBox4.Text = ThisDisplay.get_value("Texto4")
                                                                                                UserForm1.TextBox5.Text = ThisDisplay.get_value("Texto5")
                                                                                                UserForm1.ComboBox1.Text = ThisDisplay.get_value("Name1")
                                                                                                UserForm1.OptionButton1.value = ThisDisplay.get_value("Green1")
                                                                                                UserForm1.OptionButton2.value = ThisDisplay.get_value("Yellow1")
                                                                                                UserForm1.OptionButton3.value = ThisDisplay.get_value("Red1")

                                                                                             

                                                                                                UserForm1.ComboBox1.AddItem " "
                                                                                                UserForm1.ComboBox1.AddItem "Raymond, Alex"
                                                                                                End Sub
                                                                                            'Sets the lines for single space in equipment performance in text box
                                                                                            Private Sub TextBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
                                                                                                If KeyCode = 6 Then
                                                                                                TextBox3.Text = TextBox3.Text & Chr(6)
                                                                                            End If
                                                                                            End Sub
                                                                                            'Sets the lines for single space in repair notes and history in text box
                                                                                            Private Sub TextBox4_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
                                                                                                If KeyCode = 6 Then
                                                                                                TextBox4.Text = TextBox3.Text & Chr(6)
                                                                                            End If
                                                                                            End Sub
                                                                                            'clear button
                                                                                            Private Sub CommandButton2_Click()
                                                                                                TextBox1.Text = ""
                                                                                                TextBox2.Text = ""
                                                                                                TextBox3.Text = ""
                                                                                                TextBox4.Text = ""
                                                                                                TextBox5.Text = ""
                                                                                                ComboBox1.Text = ""
                                                                                               
                                                                                            'saves all fields once cleared so they show empty once form is opened again
                                                                                                ThisDisplay.store_value "Texto1", UserForm1.TextBox1.Text
                                                                                                ThisDisplay.store_value "Texto2", UserForm1.TextBox2.Text
                                                                                                ThisDisplay.store_value "Texto3", UserForm1.TextBox3.Text
                                                                                                ThisDisplay.store_value "Texto4", UserForm1.TextBox4.Text
                                                                                                ThisDisplay.store_value "Texto5", UserForm1.TextBox5.Text
                                                                                                ThisDisplay.store_value "Name1", UserForm1.ComboBox1.Text
                                                                                                ThisDisplay.store_value "Green1", UserForm1.OptionButton1.value
                                                                                                ThisDisplay.store_value "Yellow1", UserForm1.OptionButton2.value
                                                                                                ThisDisplay.store_value "Red1", UserForm1.OptionButton3.value
                                                                                            End Sub
                                                                                            'Exit button
                                                                                            Private Sub CommandButton3_Click()
                                                                                                Unload Me
                                                                                            End Sub
                                                                                            'causes object to be filled green if selected
                                                                                            Private Sub OptionButton1_Click()
                                                                                                ThisDisplay.Aircompressor3_1.FillColor = vbGreen
                                                                                                ThisDisplay.Aircompressor3_1.FillStyle = pbTBSolid
                                                                                            End Sub
                                                                                            'causes object to be filled yellow if selected
                                                                                            Private Sub OptionButton2_Click()
                                                                                                ThisDisplay.Aircompressor3_1.FillColor = vbYellow
                                                                                                ThisDisplay.Aircompressor3_1.FillStyle = pbTBSolid
                                                                                            End Sub
                                                                                            'causes object to be filled red if selected
                                                                                            Private Sub OptionButton3_Click()
                                                                                                ThisDisplay.Aircompressor3_1.FillColor = vbRed
                                                                                                ThisDisplay.Aircompressor3_1.FillStyle = pbTBSolid
                                                                                            End Sub

                                                                                            • Re: How to copy code to multiple symbols in a display?
                                                                                              dtakara

                                                                                              No worries, Alex.

                                                                                               

                                                                                              In your first post on this thread, you showed a screenshot of a tab of a UserForm where the user would include information for one of the equipments. This tab had 5 text boxes and a few other objects. In order to simply the calculation, let's just consider the 5 text boxes.

                                                                                               

                                                                                              So, with the approach we are suggesting, I understand you would need to define and use:

                                                                                               

                                                                                              (1 NamedValue/textbox) x (5 textboxes/form) x (1 form/equipment) x 134 equipments = 670 NamedValues

                                                                                               

                                                                                              When you load the UserForm upon the click on a certain equipment, you will want to manipulate the NamedValues relevant for that equipment and your code should take this into account.

                                                                                               

                                                                                              I hope it's clearer now. Please let us know if it is not and we will be happy to clarify further.

                                                                                                • Re: How to copy code to multiple symbols in a display?
                                                                                                  pisupportduke

                                                                                                  In my code given in my last post does everything look right? In manipuating NamedValues I am unsure how to go about this. I feel like I need one code to replace a lot of my existing code for this manipulation. Are you also suggesting that I am going to have to define and use 670 NamedValues or is that what I would have to do if I was to do it the long way like I started to do.

                                                                                                    • Re: How to copy code to multiple symbols in a display?

                                                                                                      Do you have a PI AF server at your disposal?

                                                                                                      • Re: How to copy code to multiple symbols in a display?
                                                                                                        dtakara

                                                                                                        Alex

                                                                                                        In my code given in my last post does everything look right? In manipuating NamedValues I am unsure how to go about this.

                                                                                                         

                                                                                                        In order to leverage the code you already developed and apply Andreas' suggestion, it seems like a simple approach would be to add a equipment-related prefix (it could be ThisDisplay.MySymbol) to the names you are giving to the NamedValues, because the quantity and types of involved user interface elements (texboxes, radiobuttons, comboboxes, etc) seem to be fixed in your use case. For example:

                                                                                                         
                                                                                                        Private Sub UserForm_Activate()
                                                                                                            UserForm1.TextBox1.Text = ThisDisplay.get_value(ThisDisplay.MySymbol & "Texto1")
                                                                                                            UserForm1.TextBox2.Text = ThisDisplay.get_value(ThisDisplay.MySymbol & "Texto2")
                                                                                                            UserForm1.TextBox3.Text = ThisDisplay.get_value(ThisDisplay.MySymbol & "Texto3")
                                                                                                            ' other commands  (...)
                                                                                                        End Sub
                                                                                                        

                                                                                                         

                                                                                                         
                                                                                                        Private Sub CommandButton1_Click()
                                                                                                            ThisDisplay.store_value ThisDisplay.MySymbol & "Texto1", UserForm1.TextBox1.Text
                                                                                                            ThisDisplay.store_value ThisDisplay.MySymbol & "Texto2", UserForm1.TextBox2.Text
                                                                                                            ThisDisplay.store_value ThisDisplay.MySymbol & "Texto3", UserForm1.TextBox3.Text
                                                                                                            ' other commands (...)
                                                                                                        End Sub
                                                                                                        

                                                                                                         

                                                                                                        Alex

                                                                                                        Are you also suggesting that I am going to have to define and use 670 NamedValues or is that what I would have to do if I was to do it the long way like I started to do.

                                                                                                         

                                                                                                         

                                                                                                        The NamedValues will be created, written and read as appropriate, if the approach I described above is applied.

                                                                                                         

                                                                                                        I hope this helps. Let us know if you need further clarification.

                                                              • Re: How to copy code to multiple symbols in a display?
                                                                dtakara

                                                                Alex

                                                                Ah I see. Move my click event from my display to each form. Makes sense.

                                                                 

                                                                 

                                                                Actually the Click event needs to remain on the code of the display and not on the code of each UserForm.

                                                                 

                                                                Alex

                                                                I have not considered writing my values as PI tags. That seems like a great idea. Can you explain how writing a PI tag history will look? Will I be able to see all of the previous forms? Would this would give me the ability to go look back at a pi tag and see when the last problem to a piece of equipment was and what work was done to it? Is my idea correct?

                                                                 

                                                                 

                                                                You can write text values to PI tags of type string. The values of string tags are limited to 976 chars though.

                                                                 

                                                                From the point of view of use case analysis, I wonder if you don't already have some application more specialized in Maintenance and Work Orders, such as Maximo or SAP PM. I am just raising this question to make sure the wheel is not being reinvented in the context of your company.