473,401 Members | 2,127 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,401 software developers and data experts.

Autonumber of new record

Is there a way to get the autonumber of a newly inserted record?

I am working with unbound forms, and using an append query to insert a
record into a table. I am then using a select query that returns the max ID
(the autonumber field) of the table. This gives me the correct number.
However, could this go wrong in a multi-user environment. I insert a
record, and say it gets ID 10, but before (even thoug it is a split second)
I read the max value, someone else inserts a record with ID 11.

What I need is a way to get the nubmer of the record I have just inserted.

Thanks
Nov 13 '05 #1
2 3791
Hey!

I have an idea: Don't allocate the running number on form open-allocate the
running number on saving. You can do this with runningnumber = "select
max([Running Number]) from Table" + 1 (hope the syntax is correct). So you
have always the actual number. This also works in a network-client
database! I hope I help you - when you have problems, feel free to write!

Ps: Sorry for my bad english, I hope you know what I mean!

best wishes Philipp

Ok i think there is a way. When you write your record in the table, before
you
"M Fisher" <m.******@uku.co.uk> schrieb im Newsbeitrag
news:xs***************@newsfe5-win.ntli.net...
Is there a way to get the autonumber of a newly inserted record?

I am working with unbound forms, and using an append query to insert a
record into a table. I am then using a select query that returns the max ID (the autonumber field) of the table. This gives me the correct number.
However, could this go wrong in a multi-user environment. I insert a
record, and say it gets ID 10, but before (even thoug it is a split second) I read the max value, someone else inserts a record with ID 11.

What I need is a way to get the nubmer of the record I have just inserted.

Thanks

Nov 13 '05 #2
Indeed in a multi-user environment, the max value (autonumber ID) is not always *your* inserted record.

You will need an extra field UserID in YourTable. This will represent the person that inserted the record.
*Your* max value now is something like: Select Max(ID) FROM YourTable Where UserID = YourUserID

--
Hope this helps
Arno R

"M Fisher" <m.******@uku.co.uk> schreef in bericht news:xs***************@newsfe5-win.ntli.net...
Is there a way to get the autonumber of a newly inserted record?

I am working with unbound forms, and using an append query to insert a
record into a table. I am then using a select query that returns the max ID
(the autonumber field) of the table. This gives me the correct number.
However, could this go wrong in a multi-user environment. I insert a
record, and say it gets ID 10, but before (even thoug it is a split second)
I read the max value, someone else inserts a record with ID 11.

What I need is a way to get the nubmer of the record I have just inserted.

Thanks

Nov 13 '05 #3

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

Similar topics

2
by: Charles Robinson III | last post by:
The AutoNumber sequence in my database is currently formatted as '000000'. When a new record is created, the AutoNumber would go from 000001, 000002, 000003 and so on. I want to track via...
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...
26
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
8
by: petebeatty | last post by:
I have created a SQL string the properly inserts a record in the table. However, the insert does not occur at the end of the table. Instead it inserts a record after the last record that I viewed....
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...
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...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
4
by: Lyn | last post by:
Hi, Is there an "easy" way to write a full record (all fields) using "INSERT INTO..." into a table which has an AutoNumber field? Normally, to write a full new record I would use: INSERT INTO...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.