All I want to do is to count the number of records which meet a specefic criteria from a table. I have done some part of the code but it doesn't work. Please help...
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenRecordset(" Select [Product] from Bulletins group by [product];"
'If there are no records in the table then the function exits
If rsMyRS.RecordCount <= 0 Then Exit Function
'Assign the selected item in the listbox as a criteria
strstring = Me!lstNumeric.Column(intCurrent)
'specify criteria for the find method
strCriteria = "[Product]= ' " & strstring & "'"
'Return an accurate recordcount
rsMyRS.MoveLast
lngRecCount = rsMyRS.RecordCount
'To start the process move to the first record of the table
rsMyRS.MoveFirst
rsMyRS.FindFirst strCriteria
Do Until rsMyRS.EOF
rsMyRS.FindNext strCriteria
Count = Count + 1
'If no match is found then exit the loop
If rsMyRS.EOF = True Then Exit Do
Loop
'Assign the counter to the total sequence
Forms!AddRec!txtSequence = Count
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenRecordset(" Select [Product] from Bulletins group by [product];"
'If there are no records in the table then the function exits
If rsMyRS.RecordCount <= 0 Then Exit Function
'Assign the selected item in the listbox as a criteria
strstring = Me!lstNumeric.Column(intCurrent)
'specify criteria for the find method
strCriteria = "[Product]= ' " & strstring & "'"
'Return an accurate recordcount
rsMyRS.MoveLast
lngRecCount = rsMyRS.RecordCount
'To start the process move to the first record of the table
rsMyRS.MoveFirst
rsMyRS.FindFirst strCriteria
Do Until rsMyRS.EOF
rsMyRS.FindNext strCriteria
Count = Count + 1
'If no match is found then exit the loop
If rsMyRS.EOF = True Then Exit Do
Loop
'Assign the counter to the total sequence
Forms!AddRec!txtSequence = Count