Last record problem

I have two sets of forms identical in construction – a custom controller and a main form which holds a two-tab tab panel. One tab is in record view, the other in table. The custom controller has first, previous, next and last record navigation buttons. One set works perfectly throughout, the other works for first, previous and next, but not last.

Coding for the “last” button is identical in both sets, yet works in one and not in the other.

This code for a “first” button works:

var tp = forms.peopleMain.elements.tabs_70.tabIndex;

if (tp == 1)
{
	forms.peoDetails.controller.setSelectedIndex(1);
}
if (tp == 2)
{
	forms.peoTable.controller.setSelectedIndex(1);
}

And so does this for a “last” button:

var tp = forms.companyMain.elements.tabs_70.tabIndex;

if (tp == 1)
{
	forms.comDetails.setSelectedIndex(currentcontroller.getMaxRecordIndex());
}
if (tp == 2)
{
	forms.comTable.setSelectedIndex(currentcontroller.getMaxRecordIndex());
}

But with this “last” button routine it goes to the right place but the setSelectedIndex function doesn’t execute:

var tp = forms.peopleMain.elements.tabs_70.tabIndex;

if (tp == 1)
{
	forms.peoDetails.setSelectedIndex(currentcontroller.getMaxRecordIndex());
}
if (tp == 2)
{
	forms.peoTable.setSelectedIndex(currentcontroller.getMaxRecordIndex());
}

The cause is likely something simple, something overlooked. I’ve spent hours pouring over this puzzle and am getting nowhere. Can anyone suggest a method to debug this?

doesn’t it do nothing??
or just doesn’t it jump to the really last value?
because if you have more then 200 rows it will only jump to what is currently the maxRecordIndex (200)

I seem to have shaken the problem loose. In trying to identify the record count of the form holding the tabpanel I added an onShow method, doing a loadRecords(relation) where the relation is the same as that of the tabpanel.

As soon as I did this the routine now works. Obvious when you think about it. I was too focused on the form that is the primary tabpanel.