Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count fields with a text value

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have a table that includes 5 text fields. These text fields have the value either "Correct" or "Incorrect" or are blank

How can I count the number of "Corrects" in a record and also display 0 if no "Corrects".

I have tried DCount and DSum but its not working.
 
Hi PWise,

Thank you for your reply. Your code works however I wanted to sum "Corrects" like:


Name Text1 Text2 Text3 Text4 Text5 Sum

Smith Correct Correct Incorrect Correct Incorrect = 3
Jones Incorect Incorrect Incorrect Correct Incorrect = 1
Hunter Incorrect Incorrect Incorrect Incorrect Incorrect = 0
 
Code:
Select iif(Text1="Correct",1,0)+ iif(Text2="Correct",1,0)+ 
iif(Text3="Correct",1,0)+ iif(Text4="Correct",1,0)+ iif(Text5="Correct",1,0)
From Tablename
 
Code:
Select [name] ,iif(Text1="Correct",1,0)+ iif(Text2="Correct",1,0)+ 
iif(Text3="Correct",1,0)+ iif(Text4="Correct",1,0)+ iif(Text5="Correct",1,0)
From Tablename 



[code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top