473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Detecting new record

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
Jan 8 '07 #1
7 2802
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OZ**************@TK2MSFTNGP03.phx.gbl...
>
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?
Jan 8 '07 #2
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.

--
HTH
Van T. Dinh
MVP (Access)

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OZ**************@TK2MSFTNGP03.phx.gbl...
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


Jan 8 '07 #3
John wrote:
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.

Jan 8 '07 #4
What exactly are trying to do in the AfterUpdate event? I think the problem
is that AfterUpdate means AfterUpdate! The record is no longer "new" because
the record has been saved!

John wrote:
>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
--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200701/1

Jan 8 '07 #5
Tomorrow never comes.

The new improved _poetical_ version of Access???

--
Cheers
Van
"Lyle Fairfield" <ly***********@aim.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
Jan 8 '07 #6
"Van T. Dinh" wrote
>Tomorrow never comes.

The new improved _poetical_ version of Access???
And "Yesterday is always past."

:-)
Jan 8 '07 #7
"Lyle Fairfield" <ly***********@aim.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com
>
Tomorrow never comes.
Data every other day. Data yesterday, and data tomorrow, but never data
today. Today isn't any *other* day, you know.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Jan 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Deano | last post by:
In my app I have lots of forms with data presented in various ways using all kinds of controls. Is there a simple way of detecting if the user has changed any data? I would like to do this so I...
9
by: D. Shane Fowlkes | last post by:
I'm using SQL Server 2000 and on my page, I'm simply creating a SQLDataReader and filling in Labels with the retrieved (single) record. However, how can I prevent from getting errors when a field...
1
by: Sharkbait | last post by:
We are trying to record browser information when a customer comes to our site. I have been able to get most basic browser information using both asp and asp.net. The only thing I’m missing is the...
2
by: Sam-Kiwi | last post by:
I've spent the last 6 months developing a pay-per-download website using ASP.NET Users purchase documents and then download them. The intention is that users are only charged for documents...
5
by: needin4mation | last post by:
Hi, I have an asp.net 1.1 application that populates data from a database. When the user changes data, they have to hit a button to update the data. The data entry form (same form that is...
6
by: luanhoxung | last post by:
dear all!! i met the headache problem in setting value for some controls in my form. i have 2 combo box in form F1. i want to set value for some textbox in F1 when i choose value from 2 combo...
1
by: gtwannabe | last post by:
I'm having a problem with a form that uses AutoNumber as the primary key. I have an Abort button to delete the current record and close the form. If AutoNumber is assigned, the code executes a...
1
by: wwwords | last post by:
Is there a general method for detecting that a user has changed the record currently visible on a form, whether this is by hitting PgUp or PgDn or clicking on a navigation button, even if no change...
14
lotus18
by: lotus18 | last post by:
Hello World I have a problem in detecting the conflict schedule (Day and Time). Day 1. M 2. T 3. W 4. TH 5. F
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.