Re: How to retrieve id of last inserted record in Access without using @@identity?
- From: "J.S." <jss@xxxxxxxxxx>
- Date: Wed, 24 Aug 2005 08:20:29 -0700
Thanks for your response, Marshall!
Best,
J.S.
--
"Marshall Barton" <marshbarton@xxxxxxxxxx> wrote in message
news:i0jeg199hp9kk8p8rso9sh6v3hif04cch4@xxxxxxxxxx
> Come on folks, an AutoNumber PK field can not be relied on
> to be anything other than unique. The AutoNumber value can
> go negative if enough records are added, and there are
> times(?) when Access might decide(?) to change it from
> increment to random.
>
> The date/time field is clearly the easiest way to reliably
> identify the order that records were entered. Given that,
> one way to get the latest record is:
>
> SELECT TOP 1 <field list>
> FROM <thetable>
> ORDER BY <datefield> DESC
>
> A way to lookup the PK field of the latest record:
>
> DLookup("PK", "thetable", "datefield = " &
> Format(DMax("datefield", "thetable"), "\#m\/d\/yyyy\#"))
>
> but that is pretty ugly and will be slow if done frequently.
>
> --
> Marsh
> MVP [MS Access]
.
- References:
- How to retrieve id of last inserted record in Access without using @@identity?
- From: J.S.
- Re: How to retrieve id of last inserted record in Access without using @@identity?
- From: Eric D via AccessMonster.com
- Re: How to retrieve id of last inserted record in Access without using @@identity?
- From: PC Data***
- Re: How to retrieve id of last inserted record in Access without using @@identity?
- From: tina
- Re: How to retrieve id of last inserted record in Access without using @@identity?
- From: Eric D via AccessMonster.com
- Re: How to retrieve id of last inserted record in Access without using @@identity?
- From: Marshall Barton
- How to retrieve id of last inserted record in Access without using @@identity?
- Prev by Date: Re: How to retrieve id of last inserted record in Access without using @@identity?
- Next by Date: Re: How to retrieve id of last inserted record in Access without using @@identity?
- Previous by thread: Re: How to retrieve id of last inserted record in Access without using @@identity?
- Next by thread: Re: How to retrieve id of last inserted record in Access without using @@identity?
- Index(es):