Count/Query/Incorrect result

Lensmeister

Registered User.
Local time
Today, 01:28
Joined
Feb 18, 2009
Messages
65
I have attached a screen dump of my problem.

I am trying to count the number of cards in a game in a query. The check boxes are ticked when a card is issued, but when I run the query (on the right) it shows a minus figure .... How come.

Please can someone advise me what's wrong.

Using Access 2003 and Windows XP

Thanks :)
 

Attachments

  • query.PNG
    query.PNG
    24.1 KB · Views: 192
You cannot sum/count a yes/no field. Create two new columns

Red:IIf([RedCard]=True,1,0)

Yellow:IIF([YellowCard]=True,1,0)

Then sum the Red and Yellow columns

IF you count you will always get the same total because a record will be counted whether it is red or yellow.
 
Thanks I will try that now.

EDIT:

Thanks it worked ... :)
 
Last edited:
You could also use the Abs function which will return a 1 for True and a 0 for False.

Red: Abs([redcard])

Abs is a very useful function, I use it a lot.
 
Thanks.

I have also the following problem similar.:

tbl_Matches
qry_OppoPerf

The query looked at the tbl_Matches
I want it to look at the table and where the team name is count the number of W in the column "R".

I used this SQL:
Code:
SELECT COUNT(*) AS [R] FROM tbl_Matches WHERE R = "W"
in the Field section of the Query ...

What am I doing wrong ?
 
Create a query and then look at the SQL.

I did sadly it didn't work.

I seem to be missing something somewhere.


in the query builder I have

Field: R
Table: tbl_Matches
Total: Count
Criteia: "W"

this returns:

data type mismatch in Criteria expression

:(
 
I did sadly it didn't work.

I seem to be missing something somewhere.


in the query builder I have

Field: R
Table: tbl_Matches
Total: Count
Criteia: "W"

this returns:

data type mismatch in Criteria expression

:(
You can't use a WHERE clause like that on a count field. You need the Actual field to put the criteria on.
 
The SQL from the above gave me this:

Code:
SELECT tbl_Matches.Opposition
FROM tbl_Matches
GROUP BY tbl_Matches.Opposition, tbl_Matches.R
HAVING (((tbl_Matches.R)="W"));
 
now I have done this and got this (see images)
 

Attachments

  • query2.PNG
    query2.PNG
    39.6 KB · Views: 161
  • query2a.PNG
    query2a.PNG
    10.2 KB · Views: 142

Users who are viewing this thread

Back
Top Bottom