Access VBA: Find max number in column and add 1

As long as the column only contains numeric values with no alpha’s then you can use:

NewNumeroCommande = Dmax("[Numero de Commande]", "Demande") + 1

Note: This is not my recommended method but just an in-built option of Access, if possible then you can save yourself the hassle by using Autonumbering, or alternatively you could have a seperate “counter” table which records the highest record number, when you wish to create another, you could lock this table, increment the value by one (and then use this) and then release the lock, this would be more effective in a multi-user environment.

Leave a Comment