The script parameter on the button for the current year would be: "*/*/" & Year ( Get ( CurrentDate ) )
Previous year: "*/*/" & Year ( Get ( CurrentDate ) ) - 1
The script would then just take that script parameter and pass it along.
Enter Find Mode 
Set Field [ YourDateField; Get ( ScriptParameter ) ]
Perform Find 
Dont forget to error trap for invalid dates, no records found, etc.
Also I just wanted to mention as a side note, you could just put in the year such as 2010 and it will find all the records in 2010 but IIRC this shortcut may not always work when dealing with other international date formats.
This makes sense, and uses something I've not tried before (script parameters).
However, when I try to insert the script parameter, it keeps returning an error screen that highlights "*/*/" and states that it is not a valid date parameter.
I tried it without and with the parentheses in various locations, including after Year, but keep getting the same error message.
Thanks for the help/
You are putting the script parameter when you specify the script for your button correct?
Correct. I was trying to write the script and would then link it to a button on a List Layout of all Activities.
I posted an image of the script screen here:
Why is there a Get ( in the beginning?
If you have time, I'm stumped. I got sidetracked on another issue for a few days after I was stuck on trying to make this work. I went back at it, and I think I'm not understanding exactly how to create a script parameter.
I just read the help page (which was no help at all) and searched the forum, and it looks like a script parameter is something that is written and can then be called into any script via Get ( ScriptParameter ). However, I cannot figure out how to actually write the script parameter. Where would they be?
You mentioned defining it off the button, but I can't figure out how.
If you can point me in a direction to look this up, I'd appreciate it.
When you set up a button to perform a script, you select the perform script options and click Specify to select the script to be run. This pops up a dialog box with an "optional script parameter" box at the bottom. You can enter a parameter in this box or click the edit button to design a calculation that will evaluate and pass its result as the parameter to your script.
That sound you heard a while ago -- thwap -- was what Click & Clack on Car Talk call a dope slap.
OK -- I found it (hiding in plain view), but when inserting the parameter mr_v recommended, it won't highlight the OK button to save.
I am putting in exactly: "*/*/"_&_Year_(_Get_(_CurrrentDate_)_) (The underscores are spaces.)
Any idea of what I'm doing wrong.
I had to play around with the dialog to replicate that.
Make sure you've clicked the name of a script so that filemaker knows which script to perform (and pass the parameter to). :smileywink:
It doesn't appear to be the issue in this case, but for expressions like this, it's a good idea to click the edit button so that you can use the script editor to build them. You get a bit more feedback on any typos that way.
Phil already pointed out what most likely the issue would be being that a script probably was not selected. However, I just wanted to add that the spaces dont matter for the calc. Its just a formatting preferance for easier readability.
you could just put in the year such as 2010 and it will find all the records in 2010 but IIRC this shortcut may not always work when dealing with other international date formats.
I believe it's the other way round: a 4-digit year by itself will work with any date format, but */*/2010 will only work with m/d/y and d/m/y formats, not y/m/d.
I would make the script parameter either -1 or empty, and the script:
Enter Find Mode 
Set Field [ YourDateField ; Year ( Get (CurrentDate) ) + Get (ScriptParameter) ]
Perform Find