Click to See Complete Forum and Search --> : How to count the number of records meeti


Anon
09-25-2001, 02:32 PM
rsoor (Visitor) Sep 25, 2001
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

mithril
09-25-2001, 08:44 PM
&lt;?php
&nbsp;&nbsp;$conn = @mysql_connect("localhost", "username", "password") or die("connection failed");
&nbsp;&nbsp;@mysql_select_db("myDB") or die ("couldn't select database");

&nbsp;&nbsp;$rs = @mysql_query("SELECT product FROM bulletins GROUP BY product");

&nbsp;&nbsp;$count = @mysql_num_rows($rs);
?>

4 lines and no endless assignment statements..... now isn't PHP your friend?:)

geoff