Applies ToAccess for Microsoft 365 Access 2021 Access 2019 Access 2016

Applies to

Form Object

You can use the NewRecord property to determine whether the current record is a new record. Read-only Integer.

expression.NewRecord

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

Remarks

The NewRecord property uses the following settings.

Setting

Description

True

The current record is new.

False

The current record isn't new.

Note: The NewRecord property is read-only in Form view and Datasheet view. It isn't available in Design view. This property is available only by using a macro or Visual Basic for Applications (VBA) code.

When a user has moved to a new record, the NewRecord property setting will be True whether the user has started to edit the record or not.

Example

The following example shows how to use the NewRecord property to determine if the current record is a new record. The NewRecordMark procedure sets the current record to the variable intnewrec. If the record is new, a message is displayed notifying the user of this. You could run this procedure when the Current event for a form occurs.

Sub NewRecordMark(frm As Form)    Dim intnewrec As Integer    intnewrec = frm.NewRecord    If intnewrec = True Then    MsgBox "You're in a new record." _        & "@Do you want to add new data?" _        & "@If not, move to an existing record."    End IfEnd Sub

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.