There are several ways, I like the "Automatic" way. I would use a new relationship on the two tables to find the "closest future date" class, if any.
1) Create a new global date field in the Class Type Table. lets call it ... gToday
2) Using a startup script or other reliable method to assure there is always a value Set Field gToday to Get (Current Date)
3) Create a New Table of Occurance for Table Class Instance on your Relationship Tab in Manage Database window, With a new TO name.
4) Connect the same relationship as the Original number pkClassType>-----<fkClassInstance
Here is the "Automatic Step" next....
5) Double click on the "=" box and get the "Edit Relationship" window. Now we are going add a New relationship logic.
6) Select gToday on the Class type and the Date field of Class Instance side and Hit the ADD button. you will see a Second Criteria appear in list as logical AND...
8) Now go to the Layout you want to Display "Next available Instance", create a new Portal selecting the new Relationship name. Sort Date field chronologically and make it a one line and one field portal, being the Date Field.
9) Lable the Portal "Next Date", if any.
10) Wahhhh Lahhhh the Next Class Instance will appear when entering that layout when you select a Class Type. It wil be empty if there are none available.
Another option that you can use in place of gToday is an unstored calculation field with get ( CurrentDate ) as its calculation and "Date" as it's result type. It will never need to be loaded with today's date, but you also cannot load it with different dates than today's--which may have uses for you. Thus, it's very much a "developer preference" as to which option to use.
@Phil i was thinking about that gToday global on second cup of coffee this morning. I was wondering if your idea would work on a Server with Multi-Clients? I hadn't tested your idea and kinda dodged the solutions. I would have probably set gToday in a script to navigate to that Layout or a Script trigger to run OnLayoutEnter.
The reason was... What if a Server changed days while still running? What would "recalculate" the gToday ?
Don't see why there'd be any problems using a calculation field so long as it is unstored. Both gToday and cToday would need something to make them update if the user is accessing the file near midnight and you wanted the value to change automatically without closing/reopeneing the file when the system clock's date changes.
Both evaluate from the client machine's perspective so hosting a file from a server doesn't change how things work.
@Phil Thanks! If you think about this post question, probably after 9:00pm it doesn't matter about the Current Day's instance. I tend to be overly careful when dealing with Server "globals" since i was 'burned big time" on my first FMP conversion to Server environment.
Or maybe just a reminder should pop up:
Hmmm, wonder if I can gin something like this up for a certain teenaged son of mind who gets way to wrapped up in his electronics...
Seriously, I don't think automatically changing the value early is a good idea, it might confuse rather than help the user. But if it was really necessary (and I doubt that it is in most circumstancs), a script trigger could perform a time check and if it's close to midnight, it could use Install OnTimer Script with a calculated interval to force an update of the value exactly when midnight is reached and the script can warn the user of the value change.