Private Sub Command16_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsType As DAO.Recordset
Dim MType As String
Dim TypeCount As Integer
Dim RecCount As Integer
Dim loopcount As Integer
Dim CurRcCount As Integer
Dim TotalTypeCount As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("Main Inventory", dbOpenDynaset)
Set rsType = db.OpenRecordset("Type of Product", dbOpenDynaset)
With rs
.MoveFirst
.MoveLast
.RecordCount = RecCount
End With
With rsType
.MoveFirst
.MoveLast
.RecordCount = TotalTypeCount
.MoveFirst
Do Until TypeCount >= TotalTypeCount
.Fields("Type of Product") = MType
With rs
.MoveFirst
Do Until CurRcCount >= RecCount
If .Fields = MType Then
Me.Label(0 + TypeCount) = MType
Me.Text(0 + TypeCount) = TypeCount
CurRcCount = CurRcCount + 1
End If
.MoveNext
Loop
End With
TypeCount = TypeCount + 1
.MoveNext
Loop
End With
End Sub