1 2 Previous Next 15 Replies Latest reply on Oct 27, 2014 4:13 PM by philmodjunk

    Layout > Data > Control style

    tays01s

      Title

      Layout > Data > Control style

      Post

      I have a series of equations whose variables appear in certain fields. For most, there's a continuous number (0 upwards) but for some variables it's 0 or 1. Obviously for the latter a radio-button would be better. Is it possible that a control style can automatically change to match the context of which record has been called?

        • 1. Re: Layout > Data > Control style
          philmodjunk

          Sort of.

          You can use two layouts and a script trigger can perform a script to switch layouts depending on the values of fields in the current record.

          Or you can have two copies of the same field--each copy with a different format and layout visibility control methods can make one appear and the other disappear as you change records.

          In FileMaker 13, it's simple as you can use the Hide Object When setting to control which copy of the field is visible.

          In older versions, we have to use some other method such as an invisible tab control and a script to make fields appear and disappear off the layout.

          Caulkins Consulting, Home of Adventures In FileMaking

          • 2. Re: Layout > Data > Control style
            tays01s

            I've got 12 Advanced so please could I ask you to expand a bit on: 2 copies, same field--each with different format ....

            When you said "use layout visibility control methods can make one appear and the other disappear as you change records."

            did you mean Conditional Formatting, Condition > formula is....?

            I can see how this would make copies of a field visible/invisible, but not how you'd arrange 1 in front of the other, that is, I've v. little space so I couldn't just have them side by side with only 1 visible.......and I can imagine someone accidentally activating the invisible one with a random click.......or am I on the wrong trail?

            • 3. Re: Layout > Data > Control style
              philmodjunk

              I was not referring to conditional formatting. Instead, you can use either an invisible tab control and a script to control which copy of the field is visible.

              This file has been made obsolete by FMP 13. Using 12, you can use Open from FileMaker's File menu to open this file and produce a copy converted to the newer file format.

              https://www.dropbox.com/s/8levaz6deiyzjr8/LayoutObjectVisibilityControlDemo.fp7

              • 4. Re: Layout > Data > Control style
                tays01s

                I have tried the script:

                Freeze Window
                If
                [ Equation::FE_name1="Septic?" ] #so if "Septic?" is chosen, the corresponding Calc::FE_1 field should be the "_1" object, a checkbox with a custom value list of "1", Else, a blank edit box. The copies of the field (Objects: Calc::FE_1_1 & Calc::FE_1_edit) sits 1 directly on top of the other.

                Go to Object [ Object Name: "Calc::FE_1_1" ] Else

                Go to Object [ Object Name: "Calc::FE_1_edit" ] End If

                I must be missing something because all I get is the edit box. I should say that Calc::__ID is related to Equation::CalcID

                • 5. Re: Layout > Data > Control style
                  philmodjunk

                  I suggest posting the exact script rather than a description. The devil is in the details.

                  To post a script to the forum:

                         
                  1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
                  2.      
                  3. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
                  4.      
                  5. If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                  6.      
                  7. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                  • 6. Re: Layout > Data > Control style
                    tays01s

                    Freeze Window
                    If
                    [ Equation::FE_name1="Septic?" ]

                    Go to Object [ Object Name: "Calc::FE_1_1" ]

                    Else

                    Go to Object [ Object Name: "Calc::FE_1_edit" ]

                    End If

                    • 7. Re: Layout > Data > Control style
                      philmodjunk

                      You appear to be using field names as object names. They are not the same thing.

                      Did you use the Inspector's name box to name the two panels of the table control Calc::FE_1_1 and Calc::FE_1_edit respectively?

                      Are you using the OnRecordLoad trigger to run this script automatically so that any time you pull up this layout or change records, the script runs to adapt to the needs of the new record?

                      Note: This method requires Form View to work. In List view, you'll see the same panel on every record become visible each time the script runs, you can't have different panels in front on different records of the list view at the same time.

                      • 8. Re: Layout > Data > Control style
                        tays01s

                        Field names: In layout > Position > Name...... I had given each of the field names a different name. If a field cannot also be an object, how would achieve having objects that represent a field?

                        Trigger: FM 12 doesn't appear to have a 'OnRecordLoad' trigger.

                        View: Yes, I'm in form.

                        • 9. Re: Layout > Data > Control style
                          philmodjunk

                          Anything on your layout can be given an object name. My point here is that the field name and the object name are two different things. And you don't need two different fields for this, just two copies of the same field placed on your layout. (To put two copies of the same field on your layout, use the field tool to add the same field twice.)

                          To give a layout object (whether it be field, layout text, button or tab control panel to name a few possibilities), enter layout mode, click to select it and then use the Name box in the inspector to give it a name. The method shown in the demo file does not give object names to the fields, though that can work. It uses object names given to the two panels of the tab control.

                          OnRecordLoad exists in all versions of FileMaker that support script triggers. You can find this trigger in Layout Setup on the script triggers tab along with all other "layout" triggers.

                          • 10. Re: Layout > Data > Control style
                            tays01s

                            Yes, I've put 2 copies of the same field (FE_1) on the layout. Each is named as an object:

                            FE_1_1: is a checkbox with a custom value list of: "1"

                            FE_1_edit: is a blank dialogue box.

                            I've set the script trigger to OnRecordLoad (I'd previously only found 'set script triggers' from the menu obtained from R clicking the object). This activates the script:

                            Freeze Window
                            If
                            [ Equation_E::FE_name1="Septic?" ]

                            Go to Object [ Object Name: "Calc::FE_1_1" ] Else

                            Go to Object [ Object Name: "Calc::FE_1_edit" ] End If

                            but whichever object is on top, stays on top; I don't get the choice. The problem may stem from the fact that the "Calc::FE_1_1" object appears regardless of whether Equation_E::FE_name1="Septic?", ie. Calc::FE_1_1 appears if anything appears in the Equation_E::FE_name1 field.

                            • 11. Re: Layout > Data > Control style
                              philmodjunk

                              To repeat, calc::FE_1_1 looks like a field name instead of an object name. You may have entered that text into the inspector's name box as an object name and then it really is the object name, but it's format is then confusing as it looks like a standard field name reference. Thus I have to ask: "are you SURE that this is the layout object's OBJECT name and not its FIELD name?

                              When you click each layout object, you should see the text in the Inspector's Name box change to show the other object name.

                              Also for the hidden tab control trick, I put the tab control on the layout as a normal, visible tab control and make sure that clicking each tab in the control works to make the display switch between the two differently formatted copies of this field. I then implement the script and change the tab control to an invisible control with zero width tab panels only after I can see that the script is working.

                              • 12. Re: Layout > Data > Control style
                                tays01s

                                OK, I've changed the object names to: FE_1_1 (checkbox) & FE_1_edit, so that they don't confuse. Both are copies of Calc::FE_1 and yes both names appear in the Inspector's name box when clicked.

                                The FE_1 field is tightly arranged with many others, already on a tab; if possible I'd just like to have the copies of the field (objects) become visible without adding another tab. Can I? Also I still don't understand why the script below doesn't work, particularly why the checkbox object is visible when any value is in Equation_E::FE_name1 rather and just the value ="Septic?"

                                If [ Equation_E::FE_name1="Septic?" ]

                                Go to Object [ Object Name: "FE_1_1" ]

                                Else

                                Go to Object [ Object Name: "FE_1_edit" ]

                                End If

                                • 13. Re: Layout > Data > Control style
                                  philmodjunk

                                  "tightly arranged" may prove to be problematic. you may need to put two complete sets of field objects inside each panel even though only one field need show the format difference. (Or upgrade to FM 13).

                                  It sounds like the script is not running at all. Put a show custom dialog inside the two parts of your if to test to see if they work or if you have FileMaker Advanced, enable the script debugger and then change records to test your script.

                                  • 14. Re: Layout > Data > Control style
                                    tays01s

                                    I've managed to get the following script working so that it does indeed cause the checkbox to 'sit on top' if FE_name1=septic, to ignore this field if FE_name1="" or bring the edit version of the FE_1 field to the top if FE_name1='any other value'. However, 'septic' causes '1' to be inserted after any other value already in the edit box and I can't edit the edit box without getting a warning (attached).

                                    1 2 Previous Next