After following and participating in various discussion about a reliable method to examine whether records are available in a related table I suggest a new function HasRelatedRecords( ForeignTable::Field )
There are various situations when this function would be helpful, especially as a check before calling the script step Go To Related Records.
Current used solutions have their flaws:
- IsValid( ) might fail if the foreign field of the relationship contains different data than the data type of the field (e.g. text in a number field)
- not IsEmpty( ) and Count( ) might fail in cartesian product relations with empty field values.
- Using ExecuteSQL( ) requires knowledge about the fields and the relation type used in the relation.It also requires a lot of typing and therefore might create careless mistakes within the sql code, and it is not an easy solution for beginners.