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...)
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]
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.
It's true you can't add a value to such a value list. But you could make a button that says "Show All"
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 ) ]
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!
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.
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
It is a small relief that it is not me. A very nice feature though, I hope it gets fixed soon.
Has anyone tested this in in FMP 12? Be nice to know if 12 did or did not fix this one...