Ok, so I have query with the following criteria: Total Classes: Count(IIf([tblDocuments]![Red]+[tblDocuments]![blue]+[tblDocuments]![green]=Yes,1,Null)). This query has some proprietary info in it so I can't show the real words so I used colors. but anyway, I want it to count the number of classes, except when there is a closed date for the class, I don't want it to count the closed class.
9 954 NeoPa 32,556
Expert Mod 16PB
Do you realise your SQL there is checking for one, and only one, of those items to resolve to Yes?
Booleans used in arithmetic don't cause the arithmetic to be Boolean Arithmetic. IE. Each Boolean True resolves to -1 (In Jet/ACE - 1 in SQL Server) and Yes, is also True of course.
Thus, any more, or less, of those values that are True will make the result either less than -1 or 0. Compare that to Yes (-1) and it just won't match.
For an answer to your full question you'll need to include the full question, of course. It's perfectly acceptable to obscure names as you have done, but if you only post a fraction of the relevant details you may wait a while for help.
I think it would be helpful to know what possible values one could expect from tblDocuments!Red.
for example between - 1000 and 5000
0 or -1 only
Between Aaron & Zebedee
I assume Blue & Green will give similar results
Phil
let me see if I can say this without getting in trouble...LOL. I have 3 different document sets. Green documents, blue document, and red documents. I want the query to count each color and return a total. But if a document has a destruction date, I don't want the query to count it. All the documents are represented by a checkbox. So for example if I have a document and it is red, I check the red box, if it is blue I check the blue box, ect... but when I get rid of that document it has a destruction date. so I want to count each color document for a total color but if it has a destruction date don't count it..Thanks for all the help
So let's just deal with one document set -
DCount("Documents", "GreenDocuments", "DestructDate is Null")
-
This should count all the documents without a destruction date.
Then all you have to do is a similar thing for the other colours and add them up.
You must appreciate that unless we have the table details, or at least an accurate layout of the table, we can't guarantee the answer.
Something like -
TblRedDocuments
-
RedDocID Autonumber
-
RedDocName Text
-
RedDocDectructDate Date
-
then we would be much better able to help
Phil
Here is a sample of my DB.
In your sample data, in Table 1, Document 4 has no colours selected, and document 5 has both blue & green.
Is this a typo?
What totals are you expecting for each of the three columns?
Phil
yeah just typos, I want the total of each color in each column and then I will add a total column for all colors, but once again, if there is a destroyed date, don't count it.
NeoPa 32,556
Expert Mod 16PB
You may be looking for something like : - Total Classes: -Sum(IIf([DocumentDestroyed] Is Null,[chkRed]+[chkBlue]+[chkGreen],0))
Bear in mind, this relies on the value of a Yes column equating to -1. It also relies on your having controls as named tied to the fields.
Aggregate functions (as used here) deal with values on the report or form. Domain Aggregate functions work with a specified record source.
Your query picture doesn't give much away. If you want to share your query then the SQL is a much more reliable way to do so. Otherwise, a description of what you're doing is required, which is still missing. You give a couple of details but there are still gaps in the overall picture. Are you including all records in the results? Are they grouped in any way (If not then you'll only get one record in the result)?
PS. Please make sure you fix any typos before posting in future. It's a shame to waste so much of people's time for the simple want of a little care.
I would add that if there are only 3 types of properties (red, green & blue) for your document, then your table structure is just about acceptable. To me it doesn't really look normalised and I would have a separate table of "Colours" -
TblColours
-
ColourID Auto PK
-
Colour Text (No duplicates)
-
And in your Docoment table -
TblDocuments
-
DocID Auto PK
-
DocName Text
-
ColourID Long FK Required
-
That way there is no possibility of having anything but 1 "colour" per document.
Phil
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
I have a complex statement that is used in a SELECT statement. After
all my calculations I need to do an additional filter on the results.
Can I use an alias anywhere or is the AS clause just for...
|
by: Steven An |
last post by:
Howdy,
I need to write an update query with multiple aggregate functions.
Here is an example:
UPDATE t
SET
t.a = ( select avg(f.q) from dbo.foo f where f.p = t.y ),
t.b = ( select sum(f.q)...
|
by: Job Lot |
last post by:
Is it possible to use Aggregate functions with GROUP BY Clauses on DataTable. I have a DataTable with following values:
Date Amount Int Balance
1/1/2004 5000.00 50.00 5050.00...
|
by: jc |
last post by:
Hi.
Just as we have AVG(COLUMN_NAME) and MAX(COLUMN_NAME) how can I write
my own variation of a such a function. If I can appreciate how to do
this,
then I hopefully I can write a...
|
by: eddiec |
last post by:
hi everyone,
I have a report in an adp that uses aggregate functions in its record source
and I am trying to figure out how to filter the records displayed in the
report:
DoCmd.OpenReport...
|
by: neb |
last post by:
Dear member of the forum,
Ms access has built-in aggregate function like:
-Sum, Max, First, Avg, ...
Is it possible to build user-defined aggregate?
(if you have any clue, do not hesitate to...
|
by: Not Me |
last post by:
Hey,
I have a report featuring a handful of subreports, a field taking values
from the main record source, and a field in the report footer which
displays the sum of values in said field.
The...
|
by: David Garamond |
last post by:
What do people think of adding some more aggregate functions. These are
the ones that MySQL has and PG doesn't:
- STD/STDDEV
- VARIANCE
- BIT_OR
- BIT_AND
- GROUP_CONCAT (for strings, added...
|
by: Dean |
last post by:
Has anyone toiled with creating/using alternate domain aggregate
functions? I have been messing with that a little. The one
recordsource I have been working indicates I get 20 to 40% savings in...
|
by: gobwash |
last post by:
Do aggregate functions (sum, count, min, max) inherently cause table
locks?
More concretely, would the following query typically result in a table
lock?
select sum(quantity) as total
from...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |