DCount with AND

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

these work separately


Count1 = DCount("Name", "Table1", "[Name] = '" & Me![Name] & "'")

Count2 = DCount("Place", "Table1", "[Place] = '" & Me![Place] & "'")


But then I realized they were of course counting separately and I really
need one count based on the 2 criteria.....so I tried to glue them together
but it throws a type 13 data mismatch

Count1 = DCount("Name", "Table1", "[Name] = '" & Me![Name] & "'" AND
"[Place] = '" & Me![Place] & "'" )

am baffled at the moment and would welcome assist....TIA
 
In
NetworkTrade said:
these work separately


Count1 = DCount("Name", "Table1", "[Name] = '" & Me![Name] & "'")

Count2 = DCount("Place", "Table1", "[Place] = '" & Me![Place] & "'")


But then I realized they were of course counting separately and I
really need one count based on the 2 criteria.....so I tried to glue
them together but it throws a type 13 data mismatch

Count1 = DCount("Name", "Table1", "[Name] = '" & Me![Name] & "'" AND
"[Place] = '" & Me![Place] & "'" )

am baffled at the moment and would welcome assist....TIA

You've got the AND outside the quotes. Try this:

Count1 = DCount("Name", "Table1", _
"[Name] = '" & Me![Name] & _
"' AND [Place] = '" & Me![Place] & "'")

You should be aware that if either Me!Name or Me!Place contains the
single-quote character ('), that expression will fail. There are easy
ways to program around that, if you need to.
 
Back
Top