Search code examples
livecode

How to update a recordset in livecode


I am using the code below to update the underlying database when users make change to a dataentry field which is displaying data from a recordset.

on CloseField

put "Update tblCases Set fldComment='" & field "txtComments" 
& "' Where fldCaseID=" &
revDatabaseColumnNamed(intRecordsetID,"fldCaseID")  into strSQL 
runSQL strSQL

end CloseField

The underlying dabase is updated as expected but the recordset is not. So when the user move to another record then come back to the record that was updated the old data is displayed.

So I need a way to refresh the database which still displaying the current record.

`


Solution

  • To enhance efficiency, the record set is saved to memory. When you go back to the previous records, you don't go to the actual records of the database but to the records that were saved in memory. To update the record set, you need to run your query again, basically deleting the old cursor and creating a new one with the new data.