Re: How to retrieve id of last inserted record in Access without using @@identity?



> With Max you will always
> get the last record entered because the last record entered always has the
> highest ID if you are using autonumbers.

that should hold true if the Autonumber field's NewValues property is set to
Increment, but not necessarily if the NewValues property is set to Random.

hth


"PC Data***" <nospam@xxxxxxxxxxx> wrote in message
news:eQxNe.320$I93.165@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Be Careful!
>
> This solution gives you the last record in the recordset. It may or may
not
> be the last record entered depending on if the table was filtered and
saved.
> A safer solution is to use Max rather than Last. With Max you will always
> get the last record entered because the last record entered always has the
> highest ID if you are using autonumbers.
>
> --
> PC Data***
> Your Resource For Help With Access, Excel And Word Applications
> resource@xxxxxxxxxxxxxxx
> www.pcdata***.com
>
>
> "Eric D via AccessMonster.com" <forum@xxxxxxxxxxxxxxxxx> wrote in message
> news:531A2D0B69123@xxxxxxxxxxxxxxxxxxxx
> > Create a new query, based on the table your ID field is in.
> > Select the ID field
> > Click on Totals - in the Tool Bar
> > Add LAST to the Totals field in the column for ID
> > Run the query.
> >
> > End result: Last ID posted to the database.
> >
> > SELECT Last(YourTable.ID) AS LastOfID
> > FROM YourTable;
> >
> >
> > J.S. wrote:
> >>In SQL server one can use @@Identity to return the id of the last
inserted
> >>record (although there are situations when it is not appropriate. What
is
> >>the best way to insert the id of the last inserted record in the last
2-3
> >>versions of Access?
> >>
> >>Thanks,
> >>J.S.
> >
> >
> > --
> > Message posted via http://www.accessmonster.com
>
>


.


Loading