// Update or insert the record in the collection
if not (CachedUpdates and Applying) then
begin
if Updating then
begin
// Log the change
RecordToChangeLog(Records.RecordAt(FCurRec), b, 'U', 0, FCurRec);
// Save the change to the Record collection
SaveRecordData(b, FCurRec);
end else begin
// Create a new item in the Record collection
r := Records.NewRecord(FCurRec, Filtered);
if (FCurRec < 0) or (FCurRec >= Records.RecordCount) then
FCurRec := Records.RecordCount - 1;
SaveRecordData(b, FCurRec);
Inc(FLastBookmark);
if not CachedUpdates then Inc(RowsAdded);
r.Bookmark := FLastBookmark;
r.BookmarkFlag := bfCurrent;
b.Bookmark := r.Bookmark;
// Log the change
RecordToChangeLog(nil, b, 'I', r.Bookmark, FCurRec);
end;
end;