Public Function GetRandomIDs(TotalNames As Long, StrSQL As String)
   ' Prior to running this funtion, other code will need to determine the TotalNames (not including previous winners) via an SQL recordset inquery.
   ' TotalNames as argument is all that is needed to calculate all ID's
   ' There is no direct return value but five new tempvars will be set.
   ' They will be used to populate an SQL query of the five display names for each unbound box use in LuckyDraw main form.
  
   ' The Win table is the key to showing the winners list and eliminating duplicate names being selected or displayed on the main form.
  
   ' The assumption with TBLNAMELIST is that the ID's are starting at 1 and there are no missing ID's anywhere. They are sequential.
   ' That is easy to do since we are in control of the import of the table of names.
  
   ' Darn! I just realized that it's not that simple. If winners are exclued from the query later, then this code will fail since it assumes a complete
   ' chain of unbroken ID's in sequential order. That is no longer the case after some winners are culled out of the record source.
  
   ' Hmmmmmm. Can we account for the gaps somehow by also tracking the ID's that were assigned as winners? Yes, that would work. So the answer is to
   ' reference the NLID FK that is stored in the winners table already inside this code and make the appropriate changes.
  
   ' So we need and SQL statement after all as an argument to the function, but it will be to scan for all ID's in the Win table.
  
   Dim Key1 As Long
   Key1 = rand Mod TotalNames + 1
  
   TempVars!Box1ID = Key1
  
   ' Here we do the special select case code to check for end of list wrap around and handle accordingly.
   If Key1 > (TotalNames - 4) Then
      Select Case Key1
         Case (TotalNames - 3)
            TempVars!Box1ID = Key1
            TempVars!Box2ID = (TotalNames - 2)
            TempVars!Box3ID = (TotalNames - 1)
            TempVars!Box4ID = TotalNames
            TempVars!Box5ID = 1
         Case (TotalNames - 2)
            TempVars!Box1ID = Key1
            TempVars!Box2ID = (TotalNames - 1)
            TempVars!Box3ID = TotalNames
            TempVars!Box4ID = 1
            TempVars!Box5ID = 2
         Case (TotalNames - 1)
            TempVars!Box1ID = Key1
            TempVars!Box2ID = TotalNames
            TempVars!Box3ID = 1
            TempVars!Box4ID = 2
            TempVars!Box5ID = 3
         Case TotalNames
            TempVars!Box1ID = Key1
            TempVars!Box2ID = 1
            TempVars!Box3ID = 2
            TempVars!Box4ID = 3
            TempVars!Box5ID = 4
         Case Else
            MsgBox "Unexpected Craziness Just Happened!"
      End Select
   Else
      ' No special case here, all other boxid's assigned in ascending order
      TempVars!Box1ID = Key1
      TempVars!Box2ID = Key1 + 1
      TempVars!Box3ID = Key1 + 2
      TempVars!Box4ID = Key1 + 3
      TempVars!Box5ID = Key1 + 4
   End If
End Function