This is a good case for using a global variable. You do this by adding a Public variable of type Long to a module (.bas). You'd increment it every time you needed a new document number. This is easy to do, but not that safe.
A good balance between ease of coding and safety is using a Private variable in your module, then writing a function to increment the value and return you the new value:
[tt]
Private m_NewDocNum as Long
Public Function GetNewDocNum() as Long
[tab]m_NewDocNum = m_NewDocNum + 1
[tab]GetNewDocNum = m_NewDocNum
End Function
[/tt]
If you want to get fancy, you'd use a class and the Singleton design pattern.
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.