Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Access AutoIncrement Fields

Hi guys,

I have a table in Access 97, this table have an Autoincrement field, i need to get the number of the next Increment. E.G. I have 3 rows in my table, so when i put one more row, it´ll receive number 4 in the database. I need the next value before inserting new data to the table, or after i´ve inserted the data.

I need to get from the access this Number, i´ll apreciate any help ;)



0
agamemnon
Asked:
agamemnon
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Anthony PerkinsCommented:
Depending on your Cursor Type and Cursor Location (if you are using a recordset to update) this value may not be available directly with Access 97, so you may have to resort to doing something like:

Select Max(ID) + 1 As LastID From Table1

before you update or:

Select Max(ID) + 1 As LastID From Table1

after you update.

This has complications when this database can be hit by multiple users.

Anthony
0
 
Anthony PerkinsCommented:
It is also dependant on the provider.  Are you using the Jet 4.0 provider?


Anthony
0
 
rkot2000Commented:


HOWTO: Return Record's Autonumber Value Inserted into Access DB (Q221931)

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q221931

HOWTO: Implement Multiuser Custom Counters in Jet 4.0 and ADO 2.1 (Q240317)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q240317
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RichWCommented:
Why not run a SQL statement like "Select MAX(autonumberfieldname) FROM TableName" right after you insert the new record?



0
 
RichWCommented:
Ooops.  Sorry guys.  I didn't read the MAX suggestions already entered.  My bad.
0
 
agamemnonAuthor Commented:
Thank you Guys, it´ll help me a lot...

The Max(Field) AFTER the new row was inserted solved my problem...
0
 
agamemnonAuthor Commented:
Thank you,

The problem was Solved with your suggestion of using MAX after inserting the row, i Am using ADO and jet4.0 provider :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now