Public Function Invoice() As String
Invoice = Format(Date, "yymmdd") & Format(Time, "hhmmss")
End Function
Although I call this function from a class module, it will work as well behind a form or standard module. I use it to generate a unique invoice number; however, it can be used to generate a unique record key for any purpose. The trick is to carry the time out to hundreds of a second. A 12 character text field holds the output of the function.
The best part, by setting this as a Primary Key, it can't be changed. The date the record was created will exist as long as the record.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.