>

EditMode Property

Applies To

Dynaset-Type Recordset Object, Recordset Object, Snapshot-Type Recordset Object, Table-Type Recordset Object.

Description

Returns a value that indicates the state of editing for the current record.

Return Values

The return value is an integer that indicates the state of editing. The data type is Integer.

The possible return values are:

Value

Description

dbEditNone

No editing operation is in progress.

dbEditInProgress

Edit method has been invoked, and the current record is in the copy buffer.

dbEditAdd

AddNew method has been invoked, and the current record in the copy buffer is a new record that hasn't been saved in the database.


These constants are listed in the Data Access (DAO) object library in the Object Browser.

Remarks

The EditMode property is most useful when you want to depart from the default functionality of a Data control. You can check the value of the EditMode property and the value of the action parameter in the Validate event procedure to determine whether to invoke the UpdateRecord method.

You can also check to see if the LockEdits property setting is True (-1) and the EditMode property setting is dbEditInProgress to determine whether the current data page is locked.

See Also

CancelUpdate Method, LockEdits Property.

Example

This example checks the EditMode property of a Recordset object and completes the update if the AddNew method has been invoked or the object is being edited.


Function PostChange(rstTarget as Recordset) As Integer
    If (rstTarget.EditMode = dbEditAdd) or  _
            (rstTarget.EditMode = dbEditInProgress) Then
        rstTarget.Update
        PostChange = True
    Else
        PostChange = False
    End If
End Function

Example (Microsoft Excel)

This example checks to see whether the Customer recordset in the NWINDEX.MDB database can be edited. If so, the example updates the value of the first field of the first record with the value in cell C3 on Sheet1.

To create the NWINDEX.MDB database, run the Microsoft Excel example for the CreateDatabase method.


Dim db As Database, rs As Recordset
Set db = Workspaces(0).OpenDatabase(Application.Path & "\NWINDEX.MDB")
Set rs = db.OpenRecordset("Customer")
If Not ((rs.EditMode = dbEditAdd) Or _
        (rs.EditMode = dbEditInProgress)) Then
    rs.Edit
    rs.Fields(0).Value = Worksheets(1).Cells(3, 3).Value
    rs.Update
Else
    MsgBox ("Cannot update database with cell value")
End If
rs.Close
db.Close