Select Last record in 200+ table

I assumed (always dangerous, I know) that

var nrRecords = databaseManager.getTableCount(foundset);
currentcontroller.setSelectedIndex(nrRecords);

would result in moving to the last record in the table (the form was based on). It doesn’t!

var nrRecords = currentcontroller.getMaxRecordIndex()
currentcontroller.setSelectedIndex(nrRecords);

returns the next 200 records so I suppose I could fire this until there are no more records in the table - but isn’t there a more elegant way do this?

I recognise this must be a Noob question but I’ve not discovered a solution using search on the forum, so I’d appreciate any feedback.

How would I structure a command to simply move to the last row in the table (it’s probably 000’s deep) and show it in my form?

I don’t need to step through each record or do any processing on them - simply show the last one!

TIA

Sort your records decending: done :twisted:

In SQL it’s “not done” to scroll to the last record in the table, since tables can hold up to millions of records.

The SQL way is: sorting or searching

Paul

pbakker:
Sort your records decending: done :twisted:

In SQL it’s “not done” to scroll to the last record in the table, since tables can hold up to millions of records.

The SQL way is: sorting or searching

Paul

I take your point Paul - and well made. However ( :wink: , supposing I REALLY want to gpo to the last record - what’s the most elegant way of showing that record?

See http://forum.servoy.com/viewtopic.php?f=22&t=11167 for example.

This topic has been discussed before on this form. Try searching on “last record”.

paul

pbakker:
See http://forum.servoy.com/viewtopic.php?f=22&t=11167 for example.

This topic has been discussed before on this form. Try searching on “last record”.

paul

Again thanks for your feedback Paul - but, that thread doesn’t really address the issue.

It should be very easy to simply select the index of the last record in the table - so why doesn’t this work

var nrRecords = databaseManager.getTableCount(foundset);
currentcontroller.setSelectedIndex(nrRecords);

or this

var nrRecords = currentcontroller.getMaxRecordIndex()
currentcontroller.setSelectedIndex(nrRecords);

There must surely be an easy way to get past the 200 record partial foundset limit and request the record at the last index - without the expense of looping through the entire recordset?

If you want to get to the last record without sorting or searching: yes, all records need to be retrieved.

Try this:

var nFSCount = databaseManager.getFoundSetCount(foundset);
foundset.getRecord(nFSCount);
foundset.setSelectedIndex(nFSCount);

It works, but again: you shouldn’t need this :)

Thanks All - got it!