Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6083509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:24:39+00:00 2026-05-23T11:24:39+00:00

I have a table in Microsoft Access/JET that has an AutoNumber field that’s set

  • 0

I have a table in Microsoft Access/JET that has an AutoNumber field that’s set incrementally which serves as the table’s primary key. I need to know what the value of the primary key will be for the next inserted record, but I need to know the value before the record is inserted. Using SELECT MAX([ID]) + 1 FROM [TableName]; will not work because records are routinely deleted from the end of the table. (Inserting a new record just to figure out the value is not an option either.)

I know that this is easily done in MySQL by using the SHOW TABLE STATUS command. Is there anything that will let me do this exact same thing for Access/JET using ADO, DAO, VB6 or any other available tools?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:24:40+00:00Added an answer on May 23, 2026 at 11:24 am

    You can use ADOX (Microsoft ADO Extensions for DDL and Security) to determine your autonumber field’s current “Seed” value.

    Public Function NextAutonumber(ByVal pTable As String, _
            ByVal pAutonumField As String) As Long
    
        Dim cat As Object
        Set cat = CreateObject("ADOX.Catalog")
        Set cat.ActiveConnection = CurrentProject.Connection
        NextAutonumber = cat.Tables(pTable).Columns(pAutonumField).Properties("Seed")
        Set cat = Nothing
    End Function
    

    Note this approach could give the wrong result in a multi-user situation … if another user can sneak an INSERT in between the time you retrieve the next autonumber and you actually do your INSERT. If it’s critical, you could verify whether you got the value you expected by checking SELECT @@Identity after the INSERT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using microsoft access jet sql. i have table col1 and col2 i
I have a Microsoft Access database that I connect to with the Jet Database
I have an Access table that I recently added an attachment field to. The
I am using Microsoft SQL Server. I have a Table which had been updated
I'm having trouble with Microsoft Access. I have a table of transactions for a
I have an access database which has some sql queries loaded into it. I
We have some code that archives data from a Microsoft Access database into a
In Microsoft Access, I have a query uniSelectedContacts and table possibles. Let's say in
I have three tables in Microsoft Access. I have a query that joins the
I have a link from Microsoft Access to a SQL Server table. The I/O

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.