I have typed out a file with its categories in parenthesis
(Flowers)
Lily
(Dogs - Domestic)
German Shepherd
(Flowers)
Rose
(Dogs - Domestic)
Collie
Here is the code snippet below:
Sub Categorize_Them()
Dim lngX As Long
lngX = 0
lCatNumber(lngX) = 2
Set DBZ = CurrentDb
Set CatRecSet = DBZ.OpenRecordset("Categories", dbOpenDynaset)
Set SubCatRecSet = DBZ.OpenRecordset("Sub Categories", dbOpenDynaset)
intX = 1
lngCatNumber = 1
lngSubCatNumber = 1
Open "C:\Users\POS\Documents\List of entries.txt" For Input As #1
Do Until EOF(1)
Line Input #1, strInputX
Do Until CatRecSet.EOF
lngCatNumber = lngCatNumber + 1
If CatRecSet.NoMatch = False Then
Line Input #1, strInputZ
lngSubCatNumber = lngSubCatNumber + 1
SubCatRecSet.AddNew
SubCatRecSet.Fields(0).Value = lngSubCatNumber
SubCatRecSet.Fields(1).Value = strInputZ
SubCatRecSet.Fields(2).Value = lngCatNumber
SubCatRecSet.Update
End If
If CatRecSet.NoMatch = True Then
Line Input #1, strInputX
End If
CatRecSet.MoveNext
Loop
Loop
SubCatRecSet.Close
CatRecSet.Close
Close #2, 1
End Sub
The following contains data integrity errors.