Detecting new record

J

John

Hi

In After Update event of form I am using the below code to distinguish
between a new record or an existing record;

If Me.NewRecord Then
......
Else
......
End If

Problem is that me.newrecord always returns zero (false) even if a new
record has been inserted. What is the problem and how can I fix it?

Thanks

Regards
 
A

Allen Browne

Any chance of using the form's AfterInsert event instead of AfterUpdate?

If not, you will need to declare a module-level boolean variable to indicate
if it was a new record, and set it in Form_BeforeUpdate.

1. In the General Declarations section of the form's module (at the top,
just after the Option statements):
Private mbWasNewRecord As Boolean

2. In Form_BeforeUpdate:
mbWasNewRecord = Me.NewRecord

3. In Form_AfterUpdate:
If mbWasNewRecord Then
 
V

Van T. Dinh

In the Form_AfterUpdate Event, the "recently new" Record is no longer as New
Record as it has been updated into the Table thus the NewRecord is always
False.

I am not sure what you are trying to do but try the Form_BeforeUpdate Event.
 
L

Lyle Fairfield

John said:
Hi

In After Update event of form I am using the below code to distinguish
between a new record or an existing record;

If Me.NewRecord Then
......
Else
......
End If

Problem is that me.newrecord always returns zero (false) even if a new
record has been inserted. What is the problem and how can I fix it?

Thanks

Regards

Tomorrow never comes.
 
D

Dirk Goldgar

Lyle Fairfield said:
Tomorrow never comes.

Data every other day. Data yesterday, and data tomorrow, but never data
today. Today isn't any *other* day, you know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top