question

JohnCTX-6479 avatar image
0 Votes"
JohnCTX-6479 asked

Categorizing techniques

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.

80763-screenshot-43.png


office-vba-devoffice-access-dev
screenshot-43.png (25.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers