Dcount operation

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,
 
J

John W. Vinson

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

Top