question

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

Categorzing items in a form and a subform

I have the following code snippet:
Sub Sort_Those_Subcategories()
Set db = CurrentDb
Set frmX = New Form_Categories
Set rx = db.OpenRecordset("Precategorized", dbOpenDynaset)
Dim Ctx As Long
Ctx = 1

 Do Until rx.EOF
     If frmX.Category.Value = rx.Fields(0).Value Then
         rx.MoveNext
         frmX.chdSubCat.Controls![Sub Category Number] = Ctx
         frmX.chdSubCat.Controls![Sub Category] = rx.Fields(0).Value
         frmX.chdSubCat.Controls![Category Number] = frmX.Category_Number.Value
         Ctx = Ctx + 1
     End If
     rx.MoveNext
 Loop
    
 frmX.Refresh
 frmX.Requery
 rx.Close
    
    
 End Sub

..and here is the screenshot:
82217-subcategory-screenshot.png

I want to improve or fix this source code snippet above, but I just don't know how.

Should I use the Seek or Find method of the DoCmd object, and add it to my code snippet?

Regards,

JohnCTX


office-vba-devoffice-access-dev
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