Public Function GetIndex() As String
'---------- D Steadman 2003
On Error GoTo GetIndex_Error
'---------- This code generates a unique ID
'---------- based on the time and date this function was called and 3 randomly selected
'---------- capitalised letters from 'A' through 'Z'.
'
Dim StrIndex, StrRandLett(25) As String
Dim IntN As Integer
'---------- Populate an array with the capitalised letters 'A' through 'Z' by allocating
'---------- the ASCII character value to an array element.
'
For IntN = 0 To 25
StrRandLett(IntN) = Chr$(IntN + 65)
Next IntN
'---------- Select 3 random numbers between 0 and 25 and select the corresponding array
'---------- element.
'
For IntN = 0 To 2
Randomize
StrIndex = StrRandLett(Int((25 * Rnd) + 0)) & StrIndex
Next IntN
'---------- Generate the current date and time and form it into a string. tagging the
'---------- preselected random numbers on to the front.
'
GetIndex = StrIndex & "-" & (Format(Date, "ddmmyy") & Format(Time, "hhmmss"))
Exit_GetIndex:
Exit Function
'---------- Error trap and or reporting
'
GetIndex_Error:
MsgBox Err.Description
Resume GetIndex_Error
End Function