Dcount operation

  • Thread starter Thread starter DontKnow
  • Start date Start date
D

DontKnow

Hi Guys,

Using the DCOUNT function I am receiving a n error!!

strsql = DCount("[UserID]", "Exam", "[correct] = 'yes'")

What am I doing wrong!! It is being used for the number of fields that have
a Yes in the yes/no field. The error that IO receive is:

Data type mismatch in the criteria expression.

I can make this work when I use another field but I want to count the number
of correct entries for a user??

Any help greatly appreciated!!

Cheers,
 
Hi Guys,

Using the DCOUNT function I am receiving a n error!!

strsql = DCount("[UserID]", "Exam", "[correct] = 'yes'")

What am I doing wrong!! It is being used for the number of fields that have
a Yes in the yes/no field. The error that IO receive is:

Data type mismatch in the criteria expression.

I can make this work when I use another field but I want to count the number
of correct entries for a user??

Any help greatly appreciated!!

Cheers,

A Yes/No field isn't a text string; it's actually stored as a number, -1 for
Yes, 0 for No. It will never be equal to the text string 'yes'.

Since it's either TRUE or FALSE, and a criterion evaluates to either TRUE
(retrieve the record) or FALSE (don't), all you really need is

DCount("[UserID]", "Exam", "[Correct]")

although for readability you could also use the builtin constant True (not
'True' or "True", just the word True):

DCount("[UserID]", "Exam", "[Correct]=True")
 

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

Similar Threads

Access Dcount (multiple criteria) 3
Access Dcount function in access 0
Access MS Access DCount function problem 0
DCount alwaysreturning 1 0
DCount type mismatch 4
Syntax for DCount Code 4
Problem with Criteria 3
Dcount error 15

Back
Top