View Single Post
 
Old 08-03-2021, 12:35 PM
ArviLaanemets ArviLaanemets is offline Windows 8 Office 2016
Expert
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default

It isn't reasonable to use formulas for generating an unique ID for entry, because you cant create such ID without it being dependent on record position. I.e. whenever user sorts the table, all ID's are changed - and your ID will be meaningless!

Probably is possible to create some VBA procedure which generates such ID whenever a new entry row is created, but it will be prone to faulty results (it's practically impossible to control in which order are cells filled when a new entry is filled, and which row in your table will have the new entry).

I myself prefer the approach, where:
On hidden sheet, the next ID is calculated - preferably a dynamic one (e.g. when in your table active row has ID, the next ID is equal to it, when ID field for active row in your table is empty, ID with MAX value is read from tables ID column, and 1 is added);
The cell where next ID is calculated is defined as Name;
In your table, you define Data Validation list for column where entry ID's are entered, with this defined Name as source. Now when the row has ID, the user can select only existing ID, but when ID field is empty, the user can select only predefined new ID. And for all other formulas, which use data from your table, you can ignore rows where ID field is empty!
Reply With Quote