'---------------------------------------------------------------------------------------
' Procedure : GenPartNums
' Author : Jack
' Created : 1/13/2010
' Purpose : To generate part numbers _ Acess World Forums
'how to generate a table of unique part numbers in access
'using the following template: ABC-DE where
'A=1,2,3,4,5
'B=CD,ER,FF,FE
'C=A,B
'D=43,23,12
'E=1,11,111,1111
'
'A sample part number would be 1CDA-431.
'What is the best way of generating all possible part numbers in access?
'
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'------------------------------------------------------------------------------
'
Sub GenPartNums()
'A=1,2,3,4,5
'B=CD,ER,FF,FE
'C=A,B
'D=43,23,12
'E=1,11,111,1111
Dim A(4) As String
Dim B(3) As String
Dim C(2) As String
Dim D(2) As String
Dim E(3) As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim m As Integer
Dim n As Integer
Dim Gen_No(479) As String
Dim idx As Integer
On Error GoTo GenPartNums_Error
idx = 0
A(0) = "1"
A(1) = "2"
A(2) = "3"
A(3) = "4"
A(4) = "5"
B(0) = "CD"
B(1) = "ER"
B(2) = "FF"
B(3) = "FE"
C(0) = "A"
C(1) = "B"
D(0) = "43"
D(1) = "23"
D(2) = "12"
E(0) = "1"
E(1) = "11"
E(2) = "111"
E(3) = "1111"
For i = 0 To 4
For j = 0 To 3
For k = 0 To 1
For m = 0 To 2
For n = 0 To 3
'
'**** You could adjust this next line to write to a table
'****
Gen_No(idx) = A(i) & B(j) & C(k) & "-" & D(m) & E(n)
idx = idx + 1
Next n
Next m
Next k
Next j
Next i
Debug.Print ' I put a breakpoint here to ensure the array was populated ####
On Error GoTo 0
Exit Sub
GenPartNums_Error:
MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure GenPartNums of Module Module4"
End Sub