# Last record problem

**URL:** <https://forum.servoy.com/t/last-record-problem/2869>\
**Category:** Classic Servoy\
**Created:** [October 9, 2004, 5:19pm UTC](https://forum.servoy.com/t/last-record-problem/2869 "2004-10-09T17:19:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 9, 2004, 5:19pm UTC](https://forum.servoy.com/t/last-record-problem/2869/1 "2004-10-09T17:19:55Z")

</div>

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:

```auto
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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [October 11, 2004, 2:28pm UTC](https://forum.servoy.com/t/last-record-problem/2869/2 "2004-10-11T14:28:01Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [October 11, 2004, 8:46pm UTC](https://forum.servoy.com/t/last-record-problem/2869/3 "2004-10-11T20:46:19Z")

</div>

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.
