Yes, FileMaker demoed this when they first made sub-summaries visible without requiring Preview mode.
Use a global field with a list of your reports, and put a script trigger on the field for onObjectModify. That script should check the new value of the global field, and, using If/If Else statements, run the appropriate sort order.
Thank you for responding Stephen, that is what I ended up doing. Always wondering if there was an easier way, then hard coding the sorts.
Hardcoding them is the most reliable.
After all, the sub-sum parts are hardcoded to specific sort orders, so they aren't going to change on the fly.
You do not need to hard code them per say, but there's a bit of indirection needed to accomplish this.
What you want to do is setup a field (or fields), that are calculated by reference from the field name stored in another field. Use this calculated field for your sorting and sub-totaling.
There are some caveats. 1.) Sorting on a calculated field is slower than sorting on a real field. 2.) the field will have to be a text field, which means you will get some odd values when sorting numbers as they will sort as text. To get around this, you just need to modify your calc field to pack leading zeroes into your number field values so they will sort properly. Dates can be handled the same way as numbers. Get the date as a number and pack it out with zeroes so it sorts properly.
Thanks for responding Lee, that's what I was going for initially, with the extra fields, but it was beyond my basic abilities. Plus it's only 5 (actually) 6 reports, so for me I better stick with Mr. Houston's response.
Quick follow up:
The report is working fine, but I had a little trouble figuring out how to get the correct calculation for the Trailing Grand Summary. I could not get a calculation field to work (not that anyone could not, just me), so I ended up using a merge variable and setting the summary calculation with a case function. It does work, but didnt know if this was the best way, or if there could be some problems down the road.
Most Trailing Grand Summary parts work just fine with a simple Summary field, using the Total of the Found set, depending on what total you are trying to return, of course.