Counting Specific Records

GMSRE

Registered User.
Local time
Today, 10:49
Joined
Apr 27, 2011
Messages
29
Hello,

I am working in Access 2007. I access to determine how many records I have for a specific CommunityID from the InputTable. For example I want know how many records there are for CommunityID 00001. I don’t know what is wrong with my code. It is giving a total of how many records are in the database instead of 9 records for CommunityID 00001. See code below. Your help will be greatly appreciated. Thank you.
GMSRE
Dim rCnt As Integer
rCnt = DCount("[CommunityID]", "InputTable", "[CommunityID]= 'Me.Community'")
 
Hi..

Try to define a variable criteria..:

Code:
Dim rCnt As Integer
Dim trz as string
trz =Me.Community
rCnt = DCount("[CommunityID]", "InputTable", "[CommunityID]= '" & trz & "' ")

If the value of a number of criteria..:

Code:
Dim rCnt As Integer,trz as integer
trz=Me.Community
rCnt = DCount("[CommunityID]", "InputTable", "[CommunityID]= " & trz & " ")
 
Hi Taruz,

It works. Thanks so much for your help. Greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom