Within the Filemaker Client you cannot deal with tables directly, you must communicate through a layout, which is linked to a Table Occurrence, which is associated with a table.
so the standard technique is:
Go to Layout x
Assuming you are in layout (and thus ,a table) you can use the count function to find out if there are records in a related table. If no related records, then you got nothing.This is quite useful for avoiding embarasing scripting erorrs--which has never happened to me. Note that you will need some field that you know is filled, like a primary key.
Normally at this point in your script, you don't need to know how many records there are in the related file, you only need to know 'Are there ANY records in the related file'.
Thus you did offer the correct answer earlier: Not IsEmpty( RelatedTable::UniqueKeyField ). If there are no related records, then the link to the UniqueKeyField in the related file will return 'Empty'.
So you don't need to wait whilst a 'Count' function runs through all the related records (there could be thousands), you just need to know if there are none, or one or more.
Best wishes - Alan Stirling
I try the techniques specified & post u the result.
Tks again to everyone.
Can I place the script on onlayoutEnter like this?
"if [(count(pref info::_kp_pkey)==0]
Someone else has already said this but it is worth repeating. If you don't care how many records there are then don't use Count. It is slow. Use IsEmpty(pref info::_kp_pkey). It resolves to true if there are no related records and false if there are. It can easily be switched by saying "not isempty".
Do be careful with layouts that have script triggers attached to them. It is very easy to forget that they are there.
thank you verymuch. Hope the following is okay (before trying today evening..)
if [(IsEmpty(pref info::_kp_pkey))]
In perform PrefInfo_Mandtory_chk
check the fields for empty, if so select the focus to the field on the layout.