title: VBA generating a random unique alpha-numeric string
body: <p>I need to create a Unique-ID (string) for each record as I am developing an application which allows users to access a unique URL like:</p>
  
  <p><a href="http://URL.com/BXD31F" rel="nofollow noreferrer">http://URL.com/BXD31F</a></p>
  
  <p>The code below works to create the URLIDs:</p>
  
  <pre><code>Public Function getURLID(ID As Double) As String
  
  Randomize
  Dim rgch As String
  rgch = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
  
  Dim i As Long
  For i = 1 To 5
      getURLID = getURLID &amp; Mid$(rgch, Int(Rnd() * Len(rgch) + 1), 1)
  Next
  
  End Function
  </code></pre>
  
  <p>How can I ensure that the URLID created is unique?  Do I need to query the database to ensure it has not been generated before?  The table has 5 million records.  A dlookup query would exceed the limitations of my MSAccess database.</p>
  
  <p>I have considered using the timestring to generate the URLID:</p>
  
  <pre><code> Format(Now, "yymmddhhmmss")
  </code></pre>
  
  <p>However, I only want a simple 5 character string.</p>