KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Scrolling to the selected record in your subform
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: February 7, 2007
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

When using a subform with a large set of records, only some of which are displayed in list form onscreen, 4D does not automatically scroll to display the selected record on screen. It is possible to programmatically add this feature to your subform via a few simple 4D commands, starting with the SCROLL LINES command.

The parameters to pass into SCROLL LINES are (*;"object_name";position). The initial * denotes that the Form object which you are passing is a subform. The "object_name" is that of the subform object on the form you are displaying it in. Position is passed in as a longint and is the line position of the selected record in the selection. There is an optional parameter at the end, *. If you choose to include this the selected record shows at the top of the display window. If you do not, the default is for the record to be listed at the bottom of the display window.

To obtain the selected record number there are two options:

-If the subform object is set to single selection mode you can use the "Selected record number" command.
-If the subform object is set to multiple selection mode use the "GET HIGHLIGHTED RECORDS" command.

A good place to insert this code into your form might be in the Next Record or Previous Record buttons, or in the Query if you are querying the subfield.

Documentation for SCROLL LINES:
http://www.4d.com/docs/CMU/CMU00906.HTM

Documentation for Selected record number:
http://www.4d.com/docs/CMU/CMU00246.HTM

Documentation for GET HIGHLIGHTED RECORDS:
http://www.4d.com/docs/CMU/CMU00902.HTM