473,836 Members | 1,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capture AutoNumber ID with AddNew method

I'm creating a new row in a table with via the AddNew method, where the
table ID is an Autonumber field. I want to capture the value of the ID
after I create the row. There are no other unique indices in the
table. Can I do this?

Thanks in advance.

Nov 12 '05 #1
2 10642
William Ortenberg <bi*****@pacbel l.net> wrote in
news:Hd******** **********@news svr27.news.prod igy.com:
I'm creating a new row in a table with via the AddNew method,
where the table ID is an Autonumber field. I want to capture
the value of the ID after I create the row. There are no
other unique indices in the table. Can I do this?

Thanks in advance.
Sure, after you issue the .addnew but before the .update to store
your record, you can set the ID to a memvar

memvar = !ID


Nov 12 '05 #2
"William Ortenberg" <bi*****@pacbel l.net> wrote in message
news:Hd******** **********@news svr27.news.prod igy.com...
I'm creating a new row in a table with via the AddNew method, where the
table ID is an Autonumber field. I want to capture the value of the ID
after I create the row. There are no other unique indices in the
table. Can I do this?

Thanks in advance.

I think this is what you mean.

With MyRecordset
![Field1] = Value1
![Field2] = Value2
MyID = ![AutonumberField] 'Autonumber value created when we
started adding the record
End With

ie. Get the value of your Autonumber field before your use the Update
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response
Nov 12 '05 #3

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

Similar topics

by: Jan van Veldhuizen | last post by:
I have an application which is running fine with MS SqlServer, but it should be working with Oracle as weel. At a lot of places we rely upon the ADO Recordset to return incremented identity columns. Oralce however returns null or zero. How can this be fixed easily? Dim mConn As New ADODB.Connection Dim rs As New ADODB.Recordset
by: Jon Trelfa | last post by:
I have been fighting with this script for several days and I'm finally at the end of my rope. Here's the scenario: -I have to add an entry into 1 table, called "calendar" -I must retrieve the newly created autonumber field from this record -Use the new ID number and insert it into a second table called "cal_details" --------------Begin Code-------------------- connString = "dsn=atpm"
by: Harold | last post by:
Sat I have a customers table with the fields CustomerID and Customer and I use the recordset.addnew method to add a new record to the table. What is the best way to get the CustomerID of the new record after recordset.update is executed? Recordset!CustomerID doesn't work because the recordset bookmark is on the first record. Moving to the last record doesn't work if the recordset is based on a query and the recordset is sorted. Thanks! ...
by: guy | last post by:
if i use Generics.AddNew how do I pass an object to the items constructor? I have a set of class all inheriting from a base class, all requiring one parameter on their constructor - the data passed to it will be the same independent of the class type so how do i pass it to AddNew?
by: polocar | last post by:
Hi, I have noticed a strange behaviour of CurrencyManager objects in C# (I use Visual Studio 2005 Professional Edition). Suppose that you have a SQL Server database with 2 tables called "Cities" and "Persons", and that: "Cities" has 2 fields called "IDCity" and "NameCity" "Persons" has 3 fields called "IDPerson", "NamePerson" and "IDCityAddress" with "IDCity" and "IDCityAddress" fields relationed with the classical father-child relation...
by: Thammarat charoenchai. | last post by:
After I use BindingSource.AddNew Method. (in my code is OrderBindingSource.AddNew). How can I set field value. like Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
by: fniles | last post by:
In VB6 to add a new record in a recorset, you can use the Addnew method, then set each column's value, then call the Update method. How can I do this in VB.NET ? Thank you. VB6: Private m_rs As new ADODB.Recordset m_rs.Open "SELECT * FROM myTable", adoCon, adOpenKeyset, adLockOptimistic with m_rs
by: back100y | last post by:
I have an application where I am using a DataGridView control to display DataTables stored in a DataSet. What I need to do is be able to prevent a user from adding a new if there is already a certain number of rows in the table. In addition, when the user deletes a row I need to be able to see the contents of that row and modify other rows in the DataTable appropriately. From what I understand of the DataGridView controls interaction with...
by: salzan | last post by:
Hello, I'm trying to insert a new record in my recordset using AddNew method. I can't figure out how to declare values for the controls in my recordset. Can someone give me an example. Thank you in advance for your help. Salzan
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...
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...
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,...
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...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.