473,836 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autonumber Fields & Insert Statment

Hi,

I have a table which the first field is an autonumber field as is also my
keyfield. Now I want to know if it is possible that after I do an insert
stament I can get what the value of this autonumber field. My problem is
that I cannot do a "select (max(field_name ))" cause I have multiple users
using the same table and I can have an other insert from another user while
I'm getting the max field value.

Ivan
Feb 24 '06 #1
3 1650
after that
Select @@identity

"Ivan Sammut" <sa*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,

I have a table which the first field is an autonumber field as is also my
keyfield. Now I want to know if it is possible that after I do an insert
stament I can get what the value of this autonumber field. My problem is
that I cannot do a "select (max(field_name ))" cause I have multiple users
using the same table and I can have an other insert from another user
while
I'm getting the max field value.

Ivan

Feb 24 '06 #2
Hi,

It's not that simple if you are using access.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dragon" <ta*****@hotmai l.com> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl...
after that
Select @@identity

"Ivan Sammut" <sa*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,

I have a table which the first field is an autonumber field as is also my
keyfield. Now I want to know if it is possible that after I do an insert
stament I can get what the value of this autonumber field. My problem is
that I cannot do a "select (max(field_name ))" cause I have multiple users
using the same table and I can have an other insert from another user
while
I'm getting the max field value.

Ivan


Feb 24 '06 #3
Hi,

Sorry for the previous post, you were right, you can get it executing select
@@identity , you just have to make sure of using the same connection
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:e7******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

It's not that simple if you are using access.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dragon" <ta*****@hotmai l.com> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl...
after that
Select @@identity

"Ivan Sammut" <sa*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,

I have a table which the first field is an autonumber field as is also
my
keyfield. Now I want to know if it is possible that after I do an insert
stament I can get what the value of this autonumber field. My problem is
that I cannot do a "select (max(field_name ))" cause I have multiple
users
using the same table and I can have an other insert from another user
while
I'm getting the max field value.

Ivan



Feb 24 '06 #4

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

Similar topics

3
4777
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...
35
7288
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
4
7752
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, but I can't update record in query or in form. I believe the problem is due to the source query. In source query, there is a filter to show the incomplete record ("is null" in delivery date)], but I need to re-use the job no. if the job is...
3
7902
by: ben.werdmuller | last post by:
Hi, Is there an easy way in ASP/VBscript to grab an autonumber (primary key) field just after an SQL insert? This is probably easy, but I'm stuck .. Cheers.
4
1424
by: Dan Keeley | last post by:
Hi. I'm inserting a record into a DB, how do i get the value back of an AutoNumber field so i can use it in subsequent SQL statements? At the moment I have code vaguely like this: Dim selectCMD As OleDbCommand = New OleDbCommand("INSERT into AuditItems ( ParentAuditID, section, score, comments) values('1')", conn)
3
2797
by: Swinky | last post by:
I hope someone can help me...I haven't got a clue how to do this. I have a table with several one-to-many relationships. One of the related tables has it's own one-to many relationships as well. I would like to copy a record when I am in a form and append it to the last record. To make it more complicated, I have an auto-number (primary key) on the main table and some of the related tables also. I can't do what I want to do using...
1
1592
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt work " .mysql_insert_id(); and not any other php or mysql error to tell me if anything is wrong the insert statment. To top it up, I have an echo statment of the insert statment before it executes, when I copy and paste the insert statment from...
4
38390
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 VALUES (Value1, Value2, ...); If (say) the first field (Value1) is an AutoNumber, what value can you put that will preserve the auto-increment function?
6
11775
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the contents of the form is inserted into the MS Access database. The Customer table in the database already has 30 records (with CustomerIDs 1 - 30) in it (from when the database was first created). The CustomerID field in the database is an...
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9656
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
10819
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...
1
10570
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10240
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
9355
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...
0
5641
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...
0
5811
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.