DCount with AND

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
 
D

Dirk Goldgar

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.
 

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