MS Access VBA Function – create UID starting at prescribed number

Useful function if you are taking two tables with overlapping identity key to be placed in a table that will have a further child record and you wish to separate the new keys.

Public Function WriteUID(LCounter As Long) As Long

Dim rstC As DAO.Recordset
Dim LCountStart As Double

LCountStart = LCounter

Set rstC = CurrentDb.OpenRecordset("TABLEREQUIRINGUNIQUEID")

Do Until rstC.EOF = True

rstC!UID = LCounter

LCounter = LCounter + 1



MsgBox "Finished UNIQUEID write"

End Function

About Mark

Mark Brooks a forty something individual working and living in and around Edinburgh
This entry was posted in All, MS Access, VBA Code MS Access. Bookmark the permalink.