Getting Values from the Current Record

By default, when the page runs, the recordset script object opens the table or executes the query specified in its data binding properties, and then creates a recordset. A pointer is placed at the first record in the recordset, which becomes the current record.

To display data, you need to get the values from the current record. If you are working with design-time controls and have established data binding for them, the controls are automatically updated to reflect database values.

However, if you are working with non-data-bound controls, you must copy values from the current record to the control. Values from the current record are available in the recordset's fields collection.

To get values from the current record

Tip   A good time to get the values from the current record is in a handler for the recordset's onrowenter event.

After getting a value, you typically display it in a control such as a textbox or label control. For example, the following script shows how you would display values from the current record in a set of textbox script objects called txtName, txtAddress, and so on.

txtName.value = rsEmployeeList.fields.getValue("Name")
txtAddress.value = rsEmployeeList.fields.getValue("Address")
txtCity.value = rsEmployeeList.fields.getValue("City")
areaCode = rsEmployeeList.fields.getValue("AreaCode")
phone = rsEmployeeList.fields.getValue("Phone")
txtPhone.value = areaCode & " " & phone

Note   You can only copy information from the recordset to a control if the control and recordset use the same target scripting platform. For more details, see The Scripting Object Model and Creating Forms with Design-Time Controls.

If you are displaying data in editable controls — such as textboxes — users can change the data. To save their changes and write them to the database, see Updating Records.