Counting certain records via VBA

L

lecoughlin

Hi all,
I am trying to count the number of records in my table matching a
certain criteria using the following code:

var = (DCount("*", "tblSites", "[state]=" & newProgramState))

newProgramState = Alabama, and there are 3 records in the table where
state = Alabama, however var is coming back = 0. Am I doing something
wrong?

Thanks in advance.
 
T

TonyN

Not sure if you still need a solution to this, but the following worked for me:

var = DCount("*", "tblSites", "[state] = '" & newProgramState & "'")

Hope this helps. . .

Tony N
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top