If this is a school project, I suggest you try it on your own first, but the
following will do it for all combinations of digits, uppercase, and lowercase
letters. As this is about 240,000 combinations, it will take some time. If
you don't need the lower case letters, change the dimension of strAscTable to
36, remove the third For..Next loop (36 to 61), and change the counters of
the nested loops to 0 to 35.
Dim strWS As String
Dim strAscTable(62) As String
Dim inti As Integer
Dim intj As Integer
Dim intk As Integer
Dim strSQL As String
' Read ASCII characters into array
' Digits
For inti = 0 To 9
strAscTable(inti) = Chr(inti + 48)
Next inti
' Uppercase letters
For inti = 10 To 35
strAscTable(inti) = Chr(inti + 55)
Next inti
' Lowercase letters
For inti = 36 To 61
strAscTable(inti) = Chr(inti + 61)
Next inti
For inti = 0 To 61
Debug.Print inti, strAscTable(inti)
Next inti
Exit Sub
' Nested loops to create each combination
DoCmd.SetWarnings False
For inti = 0 To 61
For intj = 0 To 61
For intk = 0 To 61
strWS = strAscTable(inti) & strAscTable(intj) &
strAscTable(intk)
strSQL = "INSERT INTO [YourTable] (YourField) " & _
" SELECT " & "'" & strWS & "'" & " AS Expr1;"
DoCmd.RunSQL strSQL
Next intk
Next intj
Next inti
DoCmd.SetWarnings True
End Sub
Sprinks
mdaisl said:
I need to write a program that will populate a three character field with
all possible combinations of alpha numeric characters.
ex:
"000"
"001"
"999"
etc.
"00A"
"00Z"
"ZZZ"
etc.