Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Retrieving an autonumber field

Posted on 1999-06-28
Medium Priority
Last Modified: 2013-12-25
How can I retrieve the autonumber field from a record I just added, I tried the following:

' created rs as a recordset and queried the database
rs("field1") = "data"
rs("field2") = "data"
id = rs("autonumfield")

but rs("autonumfield") does not return the value that was put into the field, however it does show up when I query the database.

Thanks for any help you can provide.
Question by:wrussell051197
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 1863553
Are you using Microsoft Access or SQL Server?

Author Comment

ID: 1863554
Currently I'm using MS Access, but I may be switching over to SQL in the near future. SQL is SELECT @@IDENTITY isn't it? Or something similar if I remember rightly. Right now I just need the technique to get it from Access.

Accepted Solution

DarrenJ earned 200 total points
ID: 1863555

The good old trust Microsoft Knowledge base strikes again! :-)

And for SQL Server it is @@IDENTITY, but if your using ADO it's slightly different I can help with that as well...

Author Comment

ID: 1863556
That's it, thanks!

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question