0

I am trying to add a new record (unique ID) from a UserForm in Access. I have SQL code to Select the Last ID in the table, but even this did not work. It seemed to just grab the first ID. Is there a way, so that when I click the Combobox on the Userform a new unique Id is generated based on the last table value (without adding that value to the table).

SELECT Last(IDNumber) AS Expr1
FROM tbID;

Thanks much.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Chris2015
  • 1,030
  • 7
  • 28
  • 42

1 Answers1

0

Last and First really just picks some value.

This will more likely succeed (ignoring for a moment the good advice in the comments):

SELECT Max(IDNumber) AS Expr1
FROM tbID;
Gustav
  • 53,498
  • 7
  • 29
  • 55
  • That depends. If the ID is for the vehicles of your company, these are probably not entered massively by the second. – Gustav May 20 '16 at 09:48
  • Famous last words. Design for the future. I have been doing this stuff for quite a while. – Fionnuala May 20 '16 at 09:53
  • So have I, and learned not to complicate matters beyond reason. Of course, for - say - an audit trail such a simple method won't be reliable. – Gustav May 20 '16 at 10:10