calling related form's method(s)

I have a table (T1) with a related table (T2);

a form for displaying things from T1;

on the form, I have a related tab panel, for displaying
fields from table T2.

I’ve been working on this for a day or so, and everything
has been working as expected; as I move thru records in
table T1, I can see related records in the tab panel for
table T2. A control outside of the tab panel lets me move
thru these related records.

Suddenly, I’m getting errors as I move thru records in table T1.
I have a method in the main form connected to the
onRecordSelection event; this method calls a method in the
tab panel with a statement like: “forms.MyRelatedForm.RecordChange()”

It’s in this method that I’m getting errors telling me that my fields
don’t exist - sometimes.
(I can’t get it to happen as I’m writing this, so I don’t have the
exact error message)

Is it ok for the main form to call a method in a related form? And
shouldn’t that method be able to access the (related) table’s fields?

thanks in advance.
rm.

Hi Robert,

Can you mail me a sample solution?

hi maarten;

the solution i’m working with is quite large;

i solved the problem by placing the following lines
at the beginning of each method that runs in the
related table:

if (controller.getMaxRecordIndex==0)
return;

it appears that my problem is that i’m calling methods
in the related table when there are no related records.

Hi Robert,

In general ALWAYS use this IF before you do something with related records:

if(relationname)
{
   //there are related record - so continue
}

This will make sure the relation is valid (i.e. there are records).

Hope this helps

additional note:

Safest way to check for child records is:

databaseManager.hasRecords(foundset/relationName)
if(relationname)

will only check if the relation is defined in your solution,
and NOT if there are any child records.

sounds good. thanks for the responses everybody!