Interesting problem. I would try and devise a different table structure, but it was interesting.
Here is the code I came up with:
Code:
Option Compare Database
Option Explicit
Option Base 1
Public Sub test()
Const strDelimiter As String = ","
Const Groups As Integer = 10
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim TF As Integer 'text file file number
Dim varArray 'array name
Dim UB As Integer ' array upper bound
Dim GroupNum As Integer 'how many groups
Dim i As Integer 'index for array
Dim j As Integer 'index for array
Dim x As Integer 'for looping
Dim k As Integer 'which field number
Dim sString As String
Dim sfilename As String
Dim rsName As String 'recordset name or SQL
Dim strInput As String
'-----------------------
'path to text file
sfilename = "C:\Documents and Settings\usernamePath\Desktop\TextFileName.txt"
rsName = "tst"
'-----------------------
Set dbs = CurrentDb()
'open recordset
Set rst = dbs.OpenRecordset(rsName, dbOpenDynaset)
' open text file
' Open "sfilename" For Input As #TF
TF = FreeFile
Open sfilename For Input As #TF
'loop thru text file
While Not EOF(TF)
sString = ""
' read line from text file
Line Input #TF, strInput
' split the line into an array
varArray = Split(strInput, strDelimiter)
UB = UBound(varArray)
GroupNum = UB \ Groups + 1
j = 0
k = 1
rst.AddNew
For x = 1 To GroupNum
i = 0
sString = ""
'build string
Do Until i = (Groups)
If (j + i) < (UB + 1) Then
sString = sString & varArray(j + i) & ","
End If
i = i + 1
Loop
sString = Left(sString, Len(sString) - 1)
rst.Fields(k) = sString
j = j + 10
k = k + 1
Next
rst.Update
Wend
rst.Close
Set rst = Nothing
Set dbs = Nothing
Close #TF
MsgBox "Done"
End Sub
You need the blue line "Option Base 1"
The RED text is what you can/should change.