calculating the amount of times a record appears

anglesgal

Registered User.
Local time
Today, 08:33
Joined
Mar 9, 2003
Messages
10
Hi. I wasnt sure whether this should appear in the tables or queries forum so i put it in both.

How can i calculate the number of times certain data appears in a table? i want to be able to count the number of times a certain StudentID appears in my tblOldClassLessons

i tried to use a DCount but that didnt really work. any ideas?
 
If you don't have a lot of records to check DCount() should do the trick. If you have thousands of records then a Totals query or code will be faster. Your DCount might look something like this:

Dim a As Integer
a = DCount("[StudentID]", "TableNameHere", "[StudentID] = " & Me.[StudentID])

I have assumed that you are getting the StudentID from a form in which there is a control called StudentID.

If you have trouble with DCount() then post your code as you may have a syntax error. The code above assumes StudentID is a number Data Type and not text.

hth,
Jack
 

Users who are viewing this thread

Back
Top Bottom