PC Review


Reply
Thread Tools Rate Thread

Dcount operation

 
 
DontKnow
Guest
Posts: n/a
 
      20th Apr 2010
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,
 
Reply With Quote
 
 
 
 
tbs
Guest
Posts: n/a
 
      20th Apr 2010
it should be:
DCount("1", "Exam", "[correct] = true")

"DontKnow" wrote:

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

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      20th Apr 2010
On Mon, 19 Apr 2010 22:28:01 -0700, DontKnow
<(E-Mail Removed)> wrote:

>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")

--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancelled Previous Operation on DLookup or DCount AJ Microsoft Access Forms 3 21st Jun 2007 08:18 PM
System.InvalidOperationException: The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. jesper.hvid@gmail.com Microsoft Dot NET Framework Forms 0 16th Jun 2006 07:35 AM
Re: Operation Failed or Operation aborted error messages when trying to add business note Larry Microsoft Outlook BCM 0 5th Oct 2005 11:26 PM
How can i use DCOUNT without getting error when DCOUNT returns null vasal Microsoft Access Form Coding 1 15th Dec 2004 09:48 AM
DCOUNT or not DCOUNT, that is the question Chris M. Microsoft Access Queries 2 15th Jul 2004 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:14 AM.