10 Replies Latest reply on Nov 12, 2014 4:01 PM by Stephen Huston

    Dynamically change labels


      Is there a way to dynamically change field labels. I'm using a field where a name is entered, but in some cases it's called "Primary Name" and in other cases it's called "Contact". It's dependent on another selection on the layout. I know I could probably use a script trigger with two different labels, but just wondering if there is another way to do it.



        • 1. Re: Dynamically change labels

          Make the label a calculation field instead, based on the other selection. If ( other selection = x , "Primary Name" , "Contact" )

          • 2. Re: Dynamically change labels

            Two overlapping labels with conditional formatting ?

            • 3. Re: Dynamically change labels

              Or how about a single label which changes dynamically? 


              The script attached to the pop-up is only for refresh; it isn't needed if you are going to another layout because it will refresh itself.  But I wanted to also show how you can change it on same layout.  Version fp7 and fmp12 attached.  It uses a text box to load Let() with variables using conditional formatting.  See the 'I declare variables' text box.  Technique compliments of Michael Horak from long, long ago. :^)


              Message was edited by: LaRetta

              • 4. Re: Dynamically change labels

                Obviously, there is more than one way to skin a cat.  I considered all three and came to the following conclusion.


                Creating a calculation field and then using a merge field might be the most straight forward way to accomplish this, but it does require a little setup in advance, so may lack some flexibility.


                The 2nd option of overlappting fields is definitely the easiest.


                The last option is the most unique and flexible; however, it then requires both a label and a merge variable. 


                In my case, since I only have one label that I need to dynamically change, the last opiton is probably the best choice.  However, if I had more than a couple of labels that I wanted to change dynamically, I think I'd go for the first option.


                Thanks for all the very good suggestions.

                • 5. Re: Dynamically change labels

                  One thing about using merge variables ... It doesn't require label and merge variable for EACH label - only one text box for any number of layout labels ... just load the Let(), placing all layout calcs within same text box and put it at the top of layout and send it to the back in stacking order.  Then all you have to do is create the merge variable for your various labels.  I put it on top of all data-entry layouts and then if needed, it is simple to load. 


                  And since you are working at layout level, it is safer than opening field definitions while served.  It allows major decrease in number of calculations in field definitions. FM 12.0v3 does not refresh quite as well as 11 so you may need to nudge it a bit more often than 11 (unless a v4 fixes it) but nudges are easy.  :-)

                  • 6. Re: Dynamically change labels

                    Very cool, LaRetta. Thanks for sharing.



                    • 7. Re: Dynamically change labels

                      Thanks for sharing this. But how can this be applied if I have many fields. For example I built a Table and named each Field as Field1, Field2... Field30 but I want each of this field Label with their actual name to be loaded from another Table and be displayed on the Layout. For example, I want to Map Field1 Label to Code, Field2 Label to Name, Field3 Label to Address1 etc. How can this be accompished as I do not want Field1, Field2,etc to appear as Label to the user, I rather want to use the correct name as the label. Can this be done dynamically too. Using the Name for the Label does provide the result I want during find mode as the field becomes empty. If I use Merged variable instead of the field, that seems to work, but can only work for that layout only.I will be glad to send you the FM Database that I am working on if that will give you more ideas on what I am trying to do.



                      • 8. Re: Dynamically change labels

                        Be careful with calculation fields on labels. They disappear in find mode, unless the calculation is a global field.

                        • 9. Re: Dynamically change labels

                          Okay, I'll try with global field. I already done it with variable ($$variable) using Insert Merge variable instead of Insert merged field and it worked, but the problem is that I have lots of fields and I cannot use Set field Name for variable name.



                          • 10. Re: Dynamically change labels
                            Stephen Huston

                            Two labels, stacked on top of each other, and each having a Hide When calc which is based on the data so that one appears when other disappears. No variable to script and no calc field.

                            (Be sure to apply the Hide-calc in Find Mode after figuring out which should appear for searches.)