473,666 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autonumber ID not yet visible when starting new record

When I start a new record, the <autonumberin g> 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 8291
AA Arens wrote:
When I start a new record, the <autonumberin g> 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(Aut oNumberID),Null ,AutoNumberFiel d)

You could also put this in the control if you need to know the next number
(untested)
=IIf(IsNull(Aut oNumberField),D Max("AutoNumber ID","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 <autonumberin g> 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.goo glegroups.com.. .
When I start a new record, the <autonumberin g> 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 <autonumberin g> 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 <autonumberin g> 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.DateTimeStam p = 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******** *************@g 44g2000cwa.goog legroups.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.goo glegroups.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
4766
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 birth to identical mules. So each android and a martian have primary key which is a foreign key to the parent table. Now, I want to insert a new record in 'android' or 'martian'. This can be done easily using MS-Access forms. But I want to do...
33
4280
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 setting default value to a UDF that manages the auto-numbering. Access won't take a UDF as a default value. Okay, I'll use SQL WITHOUT any aggregate functions, for the default value. Access won't do that either. Okay, I create a second...
35
7260
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 start at 51 after the last 50 records are deleted? Thanks! Traci
5
18462
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 incident, the user will click a new records button (which I created using a wizard). I need the autonumber to appear automatically when ever the new record button is clicked to add a new record. I do realize that I shouldnt use the autonumber as a...
5
3053
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
1980
by: Apple | last post by:
Is there anyone can help me to solve this problem? Thank!
4
3328
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 have very patient DBA's at the main office to answer newbie questions. Using Access 2002 with linked ODBC tables to Oracle 9 (9i? not sure), ODBC driver is SQORA32.DLL, verson 9.02.00.00. My "Error 3167: Record is deleted" comes when I use...
11
4485
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 AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
7
1921
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 now works to my satisfaction, so I tried to clear out all the dummy data so that I could start again with the real data for the application. I deleted all records from the tables, but when I tried to enter new data the fields which are of type...
0
8360
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8876
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8784
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8642
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.