I'm using FM14. In a sliding panel, I have a portal that displays different types of expenses. I've managed to write a script that is triggered by clicking a + sign beside any particular type of expense. All records for the particular type of expenses then gets displayed in a list view layout and only for the year that I started from.
From whatever year that is displayed on the list view layout, I'd like to be able to move back to the preceding year for which there is data and then the preceding one and so on.
I searched this frorum and found the following script:
Set Variable [$PrevYear ; Year ( YourTable::YourDateField ) - 1]
Enter Find Mode
Set Field [Yourtable::YourDatefield ; "*/*/" & $PrevYear )
Set Error capture [on]
Sort [Restore; no dialog] // sort them if you need a specific sort order
That script does take me back one year at a time and so its works ok, except it does not work if a particular year has no records. For instance, I have records for years 2017, 2016, 2015 and 2013 but not for 2014. So I start from 2017 and move to 2016 then to 2015, all is fine but I can't move from 2015 to 2013 because there are no records for 2014. What changes do I need to make to the above script to resolve this issue?
Thanks for your help.