"h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message news:F9C1E7A2-C9FA-4C40-AF37-A5625E063B1A[ at ]microsoft.com...
[Quoted Text] > how can i get the newest record id? (the last record entered, the id > field)
That depends on your circumstances. If you are creating the record using VBA code, the DAO and ADO objects provide a means to do it. If not, I'm not sure you can do it reliably. If your table's ID field is a consecutive autonumber (as opposed to a random one or a GUID), then you can get the maximum value of the ID field using DMax: DMax("ID", "YourTable"). However, it is possible via an append query to insert a record with a lower autonumber -- inserting it into a gap in the autonumber sequence -- and that expression would not find it.
If your table as a "WhenAdded" field that is set to the current date and time when each record is added, you could extract the record ID with the maximum WhenAdded value. But that requires you to have set up such a field in advance.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|