title: Generating consecutive invoice number in MS Access VBA, # restarting every year
body: <p>I need to generate unique invoice numbers for my Access (2010) database. The numbers should be in the format year+sequential number, e.g. 20101447 for the 1447th invoice of 2010. I looked around for a while, but a lot of the Google results suggest using an autonumber and I'm quite certain that's not a very solid way of doing it. (because autonumbers are only guaranteed to be unique, nothing else)</p>
  
  <p>The database isn't going to be used by multiple users at once for now, but I don't feel like going with a totally hacked together solution either.</p>
  
  <p><strong>EDIT</strong>
  I also found <a href="http://scottgem.spaces.live.com/blog/cns!AB37C52C6D3752C!180.entry" rel="nofollow noreferrer">this website</a> that discusses sequential numbering using the DMax function. Scenario #2 is exactly what I had in mind, and I think it's good enough for my use case. I'll make sure the user is notified in the rare (for me) event that the database got changed before completely entering and saving a new invoice.</p>
  
  <p><strong>EDIT2</strong>
  FYI: The numbering scheme isn't a fiscal requirement, but just our custom numbering. I didn't want to change without a good reason to.</p>