Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Querying field values


Message #1 by "John Bracken" <jb410002@e...> on Wed, 27 Feb 2002 11:20:50
>From: "John Bracken" <jb410002@e...>
>Date: Wed, 27 Feb 2002 11:20:50
>
>I have a VB project, which which manages an Access 97 database.
>One of the fields is auto-incremented with each new record.
>I'm trying to write an SQL query which will identify the ID of the latest
>record, then add 1 to produce the value for the next record.

If there is any chance of upgrading the db to Access 2000, you can use the 
SQL statement "SELECT @@IDENTITY" to get the primary key of the most 
recently added record. Trying to anticipate what the next ID *might* be is 
very risky: particularly if you are using Autonumber/random  fields as you 
PK, a practice which, incidently, will double the maximum number of records 
you can add to a table.

Regards,
-Toby


  Return to Index