CommitOnClose Property

Microsoft Access Visual Basic

CommitOnClose Property

       

Returns or sets a Byte indicating whether the specified form saves changed records when the form closes. Read/write.

expression.CommitOnClose

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

The value of the CommitOnClose property can be one of the following.

Setting Description
0 Closing the form discards any unsaved changes.
1 (Default) Closing the form saves any unsaved changes on the form.
2 Closing the form causes Microsoft Access to prompt the user whether to save changes.

This property can only be changed during design time. During run time, it is read-only.

Example

The following example checks the specified form to see if changes are saved when the form is closed and displays a message reporting the result.

With Forms(0)
    Select Case .CommitOnClose
        Case 0
            MsgBox "The """ & .Name & """ form discards " _
                & "unsaved changes when you close it."
        Case 1
            MsgBox "The """ & .Name & """ form saves " _
                & "changes when you close it."
        Case 2
            MsgBox "The """ & .Name & """ form asks you " _
                & "whether to save changes when you close it."
    End Select
End With