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
  • 963,270
  • 265
  • 3,804
  • 3,187
Chris2015
  • 1,004
  • 7
  • 22
  • 39

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
  • 48,886
  • 6
  • 31
  • 51
  • 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