Don't use SetItemStatus() function directly - it doesn't change every old status to any new status - you can find the problem combinations in this table:

As you see, there are some item statuses that cannot be set directly; you need a second SetItemStatus() to achieve the goal. One example: changing the row status from New! to NotModified! simply doesn't work. You need to set it to DataModified! first, then you can change it to NotModified!. Some others settings are allowed, but don't work as expected; changing from NewModified! to NotModified! will change the status to New!. To encapsulate all that complexity (and forget about it forever), create a function (named, for example, uf_set_row_status - to show it sets ROW's status, not COLUMN's) in a class of useful functions or another class in your application (maybe in the DW ancestor - in this case remove the argument adw and use this instead):

/**********************************************************************************************************************Dscr: Changes the item status of the passed row in a DataWindow.-----------------------------------------------------------------------------------------------------------------------Arg: DataWindow adw long al_row DWItemStatus a_new_status DWBuffer a_buf-----------------------------------------------------------------------------------------------------------------------Thr: n_ex // see http://forum.powerbuilder.us/viewtopic.php?f=4&t=9**********************************************************************************************************************/long ll_row_countboolean lb_work_done // sometimes we have to call SetItemStatus twice to achieve the goal; this var manages the number of callsDWItemStatus l_old_statusDWItemStatus l_changed_status

/**********************************************************************************************************************Dscr: Changes the item tatus of the passed row in a DataWindow. Works only on Primary! buffer; to work with other buffers, use the overloaded version.-----------------------------------------------------------------------------------------------------------------------Arg: DataWindow adw long al_row DWItemStatus a_new_status-----------------------------------------------------------------------------------------------------------------------Thr: n_ex // see http://forum.powerbuilder.us/viewtopic.php?f=4&t=9**********************************************************************************************************************/this.uf_set_row_status(adw, al_row, a_new_status, Primary!)