You are on page 1of 3

Primary buffer

Delete buffer

Filter buffer

Original buffer

DataStore

 NotModified!--The row or column is unchanged from the values that were


originally retrieved. If a row has this status, it does not need to be saved. If a
column has this status, it is not included in a DELETE, an UPDATE, or an
INSERT statement.
 DataModified!--The specified column or another of the columns for that row
has changed. The row is saved and the columns that have changed are made
part of the UPDATE statement. If the row has this status in the Delete buffer, a
DELETE statement is generated.
 New!--The row has been inserted into the DataWindow after a retrieve, but no
values have been specified for any of the columns. This status applies only to
rows. The row does not generate an INSERT statement, nor does it generate a
DELETE statement if the row is in the Delete buffer.
 NewModified!--This status applies only to rows. It indicates that the row has
been inserted into the DataWindow after a retrieve, and values have been
assigned to some of its columns. A new row also gets this status if one of its
columns has a default value. The row generates an INSERT statement that
includes all the columns that have DataModified! status. The row does not
generate a DELETE statement if the row is in the Delete buffer.

The GetItemStatus() function is used to determine the current status of either a row or
a column. The syntax is
DataWindowControl.GetItemStatus( Row, Column, DWBuffer)

The Row parameter identifies the row from which the status will be
obtained. Column specifies the column (either by number or name) for which you
want the status; if this is a 0, it returns the status of the row. The DWBuffer parameter
identifies the DataWindow buffer you want to check. The function returns a value of
type dwItemStatus.
The SetItemStatus() function is used to change the modification status of a row or
column to a different value. You use this function to influence the type of SQL
statements that will be generated for a row. The syntax is
DataWindowControl.SetItemStatus( Row, Column, DWBuffer, Status)

The Row parameter identifies the row for which the status will be
changed. Column specifies the column (either by number or name) whose status you
want to change; if this is 0, the status of the row is changed. The DWBuffer parameter
identifies the DataWindow buffer you want to change. The status is of type
dwItemStatus.

If you change the status of a row's modification flag, it also affects the flags of all the
row's columns and vice versa. That is, setting a row to NotModified! or New! will
cause all the columns to become NotModified!. You must be aware that not all status
changes are legal, and you might have to go through an additional step to set a row or
column to a particular status. The status might actually change to a third value that is
different from both the original and the intended values.

Table 14.1 shows the effect of changing from one status to another. An entry of Yes
means that the translation is allowed. An entry of No means that there is no change
made. If a specific dwItemStatus value is shown, it is the new status of the row or
column rather than the desired one.

Table 14.1. Valid item status modifications.

Original Status Desired Status


New! NewModified! DataModified! NotModified!
New! Yes Yes No
NewModified! No Yes New!
DataModified! NewModified! Yes Yes
NotModified! Yes Yes Yes

You can reach a desired status that is not allowed directly by changing the status to an
allowable intermediary one. For example, to change a status of New! to
NotModified!, you first must make it DataModified!.

You can encapsulate the information in this table into a function (see Listing 14.1) to
be used throughout an application, either as a global or DataWindow user object
function. This function is very useful for controlling DataWindow updates; it can
cause some rows not to save or direct others to become updates rather than inserts.

You might also like