get next value of an autoincrement field

F

frank

Hello everybody:
I would like to get the next value of an autoincremental field. I don't want
to know it by going to the last record ang getting the last value used. I
suppose access uses an internal table to mantain this sequence. Is possible
to access it?
How?

Thank you very much.
Frank
 
A

Alessandro Baraldi

frank ha scritto:
Hello everybody:
I would like to get the next value of an autoincremental field. I don't want
to know it by going to the last record ang getting the last value used. I
suppose access uses an internal table to mantain this sequence. Is possible
to access it?
How?

Thank you very much.
Frank

You have Two way to do it:

1) SELECT MAX(ID) AS LastID FROM T1
or
SELECT TOP 1 ID FROM T1 ORDER BY ID Desc

2)DMAX("ID","T1")

The first solution required Recordset usage

The 2nd no

@Alex
 
J

Jeff Boyce

Frank

The "next" value ... do you mean which value will be used next, but before
you create a record that would use it?

If you are using a JET Autonumber field, remember that it could be set to
"Random". I suspect the same is true of a SQL-Server field used as
autoincrement.

So I'm curious... why would it matter what the value was going to be on the
next record? Why do you wish to know? I ask because it may be possible to
solve the problem a different way, if we knew what problem you are trying to
solve.

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top