title: Access: Generate manual sequence number
body: <p>I have a form to generate contract number whenever the user submit what they fill in that form.
  This is the example number:<br></p>
  
  <blockquote>
    <p>00001/ABC/DEF/01/2013</p>
  </blockquote>
  
  <p>the squence number is shown by '00001'. It means the next user who submit it in the same year will get the next number which '00002'.
  to handle this I use this code in my submit button:</p>
  
  <pre><code>Dim strSQL As String, cNumber As Integer
  strSQL = "SELECT TOP 1 Contract_No FROM T_Report WHERE Year=2013 ORDER BY Contract_No DESC "
  Set rs = Db.OpenRecordset(strSQL)
  
  If rs.RecordCount &gt; 0 Then
      cNumber = Left(rs!Contract_No, 5) + 1
  Else
      cNumber = 1
  End If
  </code></pre>
  
  <p>It works fine when the user submit it in different time. The problem arise when 2 or more users generate it in the same time. For example userA and userB click the button together, they will get '00001' and '00001'. What I want is another user get '00002', '00003', and so on. Could anyone please help me?</p>