10 Replies Latest reply on May 25, 2012 9:30 AM by philmodjunk

    refreshing global variable

    Kat11_1

      Title

      refreshing global variable

      Post

      I have global variable Global Data::g_year set up as number.

      and a global varialble g_years set up as calcualtion based on g_year.  Case ( Global Data::g_year = "All" or IsEmpty( Global Data::g_year) ; "*"; Global Data::g_year )

      On a layout I have a field for g_year which is set up as a drop down field with a value list called years

      All

      ----

      2006

      2007

      2008

      2009

      2010

      2011

      2012

      with the exit script trigger on it that runs a script which finds all the recods yor the year (or years) selected in g_year.

      Enter Find Mode []

      Set Field (Files::Year; Global Data::g_years)

      Perform Find []

      My problem is that when I click on the g_field on the layout in browse mode the drop down does open up and I can bring the cursor over the item on the list but I can't seem to select it ... I made sure the field can be edited in browse mode. It alsmost seems that it is a bit of hit and miss. If I change the field's control style to edit box and than back into drop down it works. Sometimes. I suspect this has something to do with the fact that  variable g_years is based on varable g_year but i don't see how. Or is thre a problem with "refreshing" global variables. I'd appreciate your suggestions.

       

      Thank you

        • 1. Re: refreshing global variable
          philmodjunk

          Actually, you describe a global FIELD. A global variable is a different object in Filemaker databases.

          My problem is that when I click on the g_field on the layout in browse mode...

          Would g_field be Global Data::g_year on this layout?

          Is this value list a custom value list or does it refer to a table to get the values shown. (Looks like a custom value list, but let's be sure...)

          • 2. Re: refreshing global variable
            GuyStevens

            First you are using the word variable wrong. I think you want to say 'field'

            What you want is:
            - A calculation field that is NOT global to calculate:  Year ( Your Date Field )  -  Call it "c_Year"

            That field will contain the value 2012 if the date field is set to 01-01-2012

            - A Number field that IS set to global Storage that contains the dropdown with the years.   -  Call it g_Year_Search

            - Then your script can be set either to the OnObjectModify or to the OnObjectValidate script trigger event.

            And your script does:

            Enter Find Mode  -  Clear the Pause button
            Set Field [YourTable::c_Year ; YourTable::g_Year_Search]
            Set Eror Capture [On]
            Perform Find

             

            • 3. Re: refreshing global variable
              Kat11_1

              You are right. When I wrote g_field I meant Global Data:: g_year. Vlaue list is a custom value list.

              I would use a calculated field c_year field as DaSaint suggests and used that field for a value list as well but than I can't have the All item in my drop down / criteria.

              • 4. Re: refreshing global variable
                GuyStevens

                It's true you can't add a value to such a value list. But you could make a button that says "Show All"

                • 5. Re: refreshing global variable
                  philmodjunk

                  Actually, you can add "ALL" but you can't add the divider between All and the years. Wink

                  List ( Year ( Your Date Field ) ; "All" )

                  is the calculation you could use to include "All" as one of the values.

                  But it also doesn't sort All to the top of the list unless you get creative with the text used for "All" either.

                  Frankly, I can't spot any reason why your value list won't let you select a value.

                  What happens if you remove all script triggers from this field?

                  Can you then select and enter a value?

                  Or is it that you select a value, but the script fails to find the year selected?

                  personally, I'd remove the calculation field and use this step in my script:

                  Set Field [Files::year ; Case ( Global Data::g_year = "All" or IsEmpty( Global Data::g_year) ; "*"; Global Data::g_year ) ]

                  • 6. Re: refreshing global variable
                    Kat11_1

                    Thank you Phil, I like what you are suggesting for adding the All to a drop down list based on a field! Thanks!

                    But I am really stumped as to why this drop down is not working for me on this field! Grr!

                    • 7. Re: refreshing global variable
                      Kat11_1

                      I am still stuck on this  - not being able to select an item from the drop down list.

                      I am using  this concept on a couple of other reports in another file sucessfully. I've been staring at this for two days now and for the life of me can't  figure  why the item on the drop down list does not get selected.

                      One interesting thing I do notice is that on this particular report if I place the same field with the same drop down value list on it in any of the three subsummary parts it works every time! But the same field in a header part of the report does not. (it does a couple of times sfter  I made a selection in subsummary part  and than it freezes agin.) Is it possible that the problem is that I have a few subsummary parts and no body part? Again I don't know where else to look. 

                      • 8. Re: refreshing global variable
                        philmodjunk

                        The fact that it is in the header is the issue. This is a known bug in FileMaker.

                        For More Information see:     Sometimes global field in header become disabled

                        This is one of many acknowledged bugs that can be found in the Known Bug List thread here in the Report an Issue section of the forum.

                        It can also be downloaded as a database file from:    https://www.dropbox.com/s/jt09b82i0xijbu3/FMP%20Bugs.zip

                        • 9. Re: refreshing global variable
                          Kat11_1

                          Thanks Phil!

                          It is a small relief that it is not me. A very nice feature though, I hope it gets fixed soon.

                          • 10. Re: refreshing global variable
                            philmodjunk

                            Has anyone tested this in in FMP 12? Be nice to know if 12 did or did not fix this one...