Counting certain records via VBA

  • Thread starter Thread starter lecoughlin
  • Start date Start date
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.
 
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
 
Back
Top