And which layout/table is "another table/layout"?
And a layout can be "empty" by having a zero found set when the table it is based on is not empty.
Assuming you don't want to leave layout 1 for layout 2 if there are no records in the found set for layout 1, you'd use this script:
If [ Get ( FoundCount ) > 0 ]
Go to Layout [Layout 2]
Show Custom Dialog ["you cannot go to layout 2..."]
I'll have a 'play' with your suggestion.
Essentially I have a database consisting of several data tables which are inter-dependent. There is data which must be present in certain tables before data can be entered into other tables. I just need the application to be 'user-friendly' in this regard.
Thanks for your help.
In that case, much can depend on the relationships you've defined and the "table context" at the time your run your script. By "table context" I mean that the current record of the current layout's table will determine what related data in other tables are accessible at that point in time. If you change layouts, you may change the context to that of a different table or a different record and then you get different results.
Looking at your outline script above, do I replace 'FoundCount' with the tablename/fieldname that I want to query?
Sorry if I'm being a bit thick, I'm pretty new to FMP (I'm getting old and my brain hurts with trying to understand all this.
No, get ( FoundCount ) refers to the number of records present in the current layout's found set. This may not work at all for you as this may not be the table or the set of records you need to check before permitting the change in layout.
A found set is a group of records from the current layout's table. In the status area next to the green "pie chart", you'll see something like 3/300. In this example, 3 is the number of records in your found set out of 300 records in the layout's table.
I think you need to provide a more detailed description of what you are trying to do here. I need to know:
What tables are involved and how they are related? On which of these tables is your layout based?
I attach a copy of the relationship 'map' of what I have so far, each table has a matching layout which are essentially data input screens.
Each layout has an identical set of buttons for navigating between layouts.
For the proposed use of the application 'T_Setup' will hold a single record which must be entered first. 'T_Sow' is entered next and should automatically receive 'Location' data from 'T_Setup'. 'T_Cal' is next and this also receives 'Location' data from T_Setup'.
'T_Survey' is next, this recieves 'Ident' data from 'T_Sow', the whole system falls down if the relevant data isn't entered in this sequence, so what I'm trying to do is 'force' the correct sequence by disabling the aprapriate buttons on each layout.
I hope that all sounds clear to you.
T_Setup::Location either has global storage specified or is an unstored calculation. Why? (I can tell by how the relationship line connects to it.)
Can T_Setup have more than one record?
There is no requirement for 'T_Setup' to have more than one record, in fact I also need to find a way of limiting it a single record.
And yes, 'T_Setup::Location' is specified as global storage because it is displayed on all data input screen layouts.
Is this a problem?
The thing is, with Location as a global field, you don't need any record present in T_setup to use it for new records in the other tables.
Assuming one and only one record in T_Setup, You can use this variation of the original script:
If [ get (TotalRecordCount) > 0 ]
This get function counts all the records in your table, not just the found set.
Sounds good Phil,
But how do I direct the 'get (TotalRecordCount)' towards 'T_Setup' when actively in a different layout?
In this example, I don't see where that would be the case, but to check total records in a different table than that of the current layout, you can do this:
Go to Layout ["T_Setup" (T_Setup)]
If [ Get (totalRecordCount)...
Go to Layout [original layout]
//and so forth in the script
Go to layout [oringal layout]
//and so forth.
This is an example of what I meant by "table context".
In other cases, you may be able to check for the existance of related records via the relationship, but this won't necessarily count all records as it counts or checks for related records and this may not be the same thing in every case.
From T_Sow, you could use this check for records in T_Setup:
If [ IsEmpty ( T_Setup::Rec#_DBP) // at least one record exists in T_Setup]
You really are doing me proud today, I'll get back to wrestling with FMP tomorrow, my old eyes just can't take anymore.
Any hint on the best way to limit 'T_Setup' to a single record, bearing in mind that access may still be required for editing purposes?
Thanks again for all your forebearance.
With FileMaker advanced, I can set that layout up with a custom menu where a script replaces the normal new record action. The script can check and only create a new record if get ( TotalRecordCount ) is zero. This works both for selecting new record from the records menu and when using the keyboard shortcut for it.