Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

Update multiple records on the List page

Scroll Prev Next More

 

To update multiple records on the List page at the same time, you can create a new Update selected button, then choose records on the List page and click the Update selected button.

 

1. Proceed to the Page Designer screen.

 

2. Create the Update selected custom button and add the following code to the Server tab:

 

dim sql, record
DoAssignment record, button.getNextSelectedRecord()
do while isObject(record)
' set ReportsTo field to 'Bob Smith'
   sql = "Update employees set ReportsTo='Bob Smith' where KeyField=" & record("KeyField")
   CustomQuery sql
   DoAssignment record, button.getNextSelectedRecord()
loop
result("txt") = "Records were updated."

 

and to the Client After tab:

 

var message = result["txt"];
ctrl.setMessage(message);

 

The Client Before tab should be blank (delete sample code there if you have any).

See also:

Data Access Layer

Database API

Tri-part events

Button object: getNextSelectedRecord()

About SQLQuery class

AJAX helper object: setMessage()