473,387 Members | 1,597 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,387 software developers and data experts.

Autonumber ID not yet visible when starting new record

When I start a new record, the <autonumbering> ID in the field is not
updated yet, only when I fill in the first field of that record. How to
solver it?

Bart
Access 2003

Jan 1 '06 #1
9 8267
AA Arens wrote:
When I start a new record, the <autonumbering> ID in the field is not
updated yet, only when I fill in the first field of that record. How to
solver it?

Bart
Access 2003


This is normal behavior for Access, I don't think there is any way to change
this directly. Access does not want a value in a field when it is not yet a
record ....

There are two quick things you can do, although I am not sure why this is a
problem unless it is confusing the users, in the control on the form that
shows the autonumber field you could put ...

If you want it to be blank
=IIf(IsNull(AutoNumberID),Null,AutoNumberField)

You could also put this in the control if you need to know the next number
(untested)
=IIf(IsNull(AutoNumberField),DMax("AutoNumberID"," tblTable")+1,AutoNumberID)

Replace AutoNumberID and tblTable with the real names of the field and table

Hope this helps,
Roger

--
Message posted via http://www.accessmonster.com
Jan 1 '06 #2
AA Arens wrote:
When I start a new record, the <autonumbering> ID in the field is not
updated yet, only when I fill in the first field of that record. How to
solver it?

Bart
Access 2003

If you want the autonumber filled in when you go to a new record put in
a default value either in the table or the form. For example, you might
have a field called DateTimeStamp. Enter
=Now()
in the table default property.
Jan 1 '06 #3
It makes sense that the autonumber field is not assigned until you start to
add a new record.

You do NOT want to add a new record just because you moved to the new record
in the form. That would cause all sorts of problems such as concurrency
issues (if lots of users are adding records), new records that end up being
saved with all the fields blank, lots of aborted autonumber values, etc.

--
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.

"AA Arens" <ba***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
When I start a new record, the <autonumbering> ID in the field is not
updated yet, only when I fill in the first field of that record. How to
solver it?

Bart
Access 2003

Jan 1 '06 #4
salad wrote:
AA Arens wrote:
When I start a new record, the <autonumbering> ID in the field is
not updated yet, only when I fill in the first field of that
record. How to solver it?

Bart
Access 2003

If you want the autonumber filled in when you go to a new record put
in a default value either in the table or the form. For example, you
might have a field called DateTimeStamp. Enter
=Now()
in the table default property.


Having a default value assigned would not cause the AutoNumber to show up any
sooner than it otherwise would.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Jan 1 '06 #5
Rick Brandt wrote:
salad wrote:
AA Arens wrote:
When I start a new record, the <autonumbering> ID in the field is
not updated yet, only when I fill in the first field of that
record. How to solver it?

Bart
Access 2003


If you want the autonumber filled in when you go to a new record put
in a default value either in the table or the form. For example, you
might have a field called DateTimeStamp. Enter
=Now()
in the table default property.

Having a default value assigned would not cause the AutoNumber to show up any
sooner than it otherwise would.

Brain freeze. You are correct. The person could do something like this
in the OnCurrent event
Private Sub Form_Current()
If Me.NewRecord Then Me.DateTimeStamp = Now()
End Sub
Jan 1 '06 #6
For one form, I indeed use Date. So, that's solved by the trick. But at
another, no date or time and instead of that I want it jumps to a combo
and want it fills an empty string. I cannot use "", however.
I use: If Me.NewRecord Then Me.CompanyName = "".

Jan 2 '06 #7
It makes no sense to assign a zero-length string to the company name field
if you have moved to a new record.

Assuming that CompanyName is a bound field, and that this code is in the
form's Current event, this is very bad practice. In fact, you don't want to
even allow a zero length string into the field of your table.

--
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.

"AA Arens" <ba***********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
For one form, I indeed use Date. So, that's solved by the trick. But at
another, no date or time and instead of that I want it jumps to a combo
and want it fills an empty string. I cannot use "", however.
I use: If Me.NewRecord Then Me.CompanyName = "".

Jan 2 '06 #8
The practice is not so clean, that's correct. However after starting a
new record, the person has to fill it in anyway. But If Me.NewRecord
Then Me.CompanyName = "" gives an error.
Related to that, when I push the button "Go to Next Record" (standard
button, made with the toolbox-buttonbar, I can even push it beyond the
last record, and thus creating new records. How to solve this
behaviour? (While keeping my wish as started this topic). "Go to Last
Record" button works.

Jan 2 '06 #9
Assigning a zero-length string makes no sense to me.

The bound control will be Null at the new record until the user fills it in.
Surely that's what is desired without any code or unnecessary dirtying of
the new record.

If you remove the code, your other problems will probably disappear too.

--
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.
"AA Arens" <ba***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
The practice is not so clean, that's correct. However after starting a
new record, the person has to fill it in anyway. But If Me.NewRecord
Then Me.CompanyName = "" gives an error.
Related to that, when I push the button "Go to Next Record" (standard
button, made with the toolbox-buttonbar, I can even push it beyond the
last record, and thus creating new records. How to solve this
behaviour? (While keeping my wish as started this topic). "Go to Last
Record" button works.

Jan 2 '06 #10

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

Similar topics

3
by: Ilan Sebba | last post by:
I have a 'supertype' table with only one field: autonumber. Call this table the 'parent' table. There are two subtypes, 'androids' and 'martians'. Martian have only one thing in common: they give...
33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
35
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
5
by: ndn_24_7 | last post by:
Hello all, I'm designing a incident reporting program that allows our security department to record incidents. The problem i'm having is on a form, when ever a user is going to add a new...
5
by: Apple | last post by:
May anyone can teach me how to assign a autonumber, I want to create a number that is starting with year(auto change to year 2006) + autonumber (eg. 2005-0001, 2005-0002)
2
by: Apple | last post by:
Is there anyone can help me to solve this problem? Thank!
4
by: dhcomcast | last post by:
We're starting to use Oracle for the back-end instead of a separate Access .mdb file for the data and everything as gone surprisingly well so far. We are learning Oracle as we go; Yikes! But we...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
7
by: RobertJohn | last post by:
I am using Access 2007 and have developed a small database application with three main tables. During the development stage I trialled the forms, relationships, reports, etc using dummy data. It...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.