Click to See Complete Forum and Search --> : counting records in a table
how exactly do i count the records in a table by a date.
the date is entered as a number long
yyyymmdd
i want to use a variable for the date
any help is greatly appreciated
Wen Lie
Jul 28th, 1999, 07:18 AM
I can't exactly know what you mean...
But maybe this will help...
Try to save the date in a variable...
then..
Open the table which date is same with the contents in that variable.
If, open succesful (Records found), then, you loop it....
e.g :
dim vardate as date
vardate=datefield
MyConn.Open "DSN=dsnName"
MyRec.Open "select * from tablename where datefield = '" & vardate & "'", MyConn, adOpenDynamics, adLockOptimistic, adCmdText
If (MyRec.BOF<>True) and (MyRec.EOF<>True) then
MyRec.MoveFirst
RecCounter = 0
Do While Not MyRec.EOF
RecCounter = RecCounter + 1
MyRec.MoveNext
Loop
Else
msgbox "Record not found"
Endif
MyRec.Close
I hope it would Help you......
Ciaooooo
Best Regards,
Wen Lie
MartinE
Aug 2nd, 1999, 07:29 PM
There is an much easier way - "SELECT count (*) FROM " & tablename & " WHERE date=" & date.
With this statement you will get a recordset with just one entry - the recordcount
Jamppa
Aug 3rd, 1999, 01:11 PM
Answer wich MartinE gave you isnīt just much easier but also more effective and faster way of counting recordsets.
Jan
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.