Try a script
Enter Find Mode [ no restore ]
Go to Layout [ LayoutToSearch ( TableToSearch ) ]
Set Field [ TableToSearch::fieldToSearch ; $x ]
Set Error Capture [ on ]
Set Variable [ $foundID ; TableToSearch::id )
Go to Layout [ original ]
# [ use $foundID ]
or, if you want to delve into SQL:
ExecuteSQL ( "
WHERE fieldToSearch = ?
" ; "" ; "" ; $x
or create a relationship based on a utility field and the field to search, set the utility field to $x and read the value from the related record (if any).
Consider what to do in these scenarios if there is more than one record where fieldToSearch matches $x.
there are many ways to go about this. Is the value you are searching for unique in the table? record set? Is the record number really what you want?
There's a method of populating a global field in your parent table with the search criteria. This global field is then related to the data field in your child table. This relationship can be used to retrieve the primary key of the child record.
Please note that a Record number as returned by the Get ( Recordnumber ) function is just the record's position in the current found set. So it's important to distinguish between getting a record's unique ID--best gotten from a field set up as the primary key in your table, from it's current position in the found set--which can change simply by performing a find or re-sorting your records.
Thanks. I used SQL and left all that record number business aside. Worked like a charm.