Finding the record with the maximum value in a query (3 Viewers)

As this thread clearly exposes, seasoned developers find “… but in this case it will be ok” incomprehensible 😜
 
As this thread clearly exposes, seasoned developers find “… but in this case it will be ok” incomprehensible 😜
I'm sure that's based in good professional sense. I, OTOH, have a very controlled situation with limited consequences.
 
Rather late, I thank you for this confirmation of what I found to work (in orig post). (Top 1 from ContactID Desc)
it is the same as using Dmax(ContactID).
again it will give you the highest autonumber (if contactID is autonumber) but does not
guarantee that it is the "most recently added member".
since there is known issue with Autonumber being "jumpy".
meaning, you can manually insert an autonumber (using sql) that does not exists and
that will be the start of the new seed.

take for example contactID's 1, 2, 3
supposed that the "most recently added ContactID = 3.
you delete record with ContactID 2, still the most recent is 3.
now, you
you insert a record using SQL, bringing back ContactID=2 (because you are thinking to prevent the gap).
Code:
insert into YourTable (ContactID, FirstName) Values (2, "SampleName")
using either DMax() or "Select Top 1 ContactID from YourTable Order By ContactID Desc;"
will bring ContactID = 3 as your result (and you think this is correct?)
now, try the Last() and it will return 2 (which is correct, the most recent record).
 

Users who are viewing this thread

Back
Top Bottom