This seems like it should be really easy and I think I'm just missing something really dumb.
I have a form that filters a report. At the top of the report I have a bunch of unbound text boxes that do simple things like count and sum. When I apply the filter to the report the text boxes update beautifully when their control source is something like
However now I want to apply a clause. If I do this: - =dcount("[num hatched]", "[tbl_nesting]","[num hatched]>0")
then I get a number but it's ALWAYS that number despite the filter. I want it just to count what's displayed after the filter but
doesn't work, just reports a false count.
What am I doing wrong?
Got it. I needed an IIF statement. - =Count(IIf([Num Hatched]>0,0))
7 5484 NeoPa 32,556
Expert Mod 16PB
There's quite a difference between the Aggregate functions and the Domain Aggregate functions.
In a report a Domain Aggregate function (DCount()) is self-contained. You must specify the record source etc. With an Aggregate function (Sum()) it refers to controls accessible (generally in the Detail section) in your report. Not fields notice (which are references to the underlying data source), but the controls.
NeoPa 32,556
Expert Mod 16PB
You also mention filtering the report. As far as I'm aware, filtering is always applied to the recordsource, and is never effected by the values in controls. Does this help to understand?
Kind of. I had figured out that Count was going to work better than DCount, but I can't figure out how to phrase the statement I want with the rule applied (e.g. count, which works, vs. count where field value > 0, which doesn't work). Can you apply a rule like that in an aggregate function? I am useless with the expression builder - it is not very intuitive to me.
Got it. I needed an IIF statement. - =Count(IIf([Num Hatched]>0,0))
NeoPa 32,556
Expert Mod 16PB AccessIdiot: - =Count(IIf([Num Hatched]>0,0))
You did, but I suggest one more like : - =Count(IIf([Num Hatched]>0,1,0))
Can you translate that into a full sentence for me? I didn't fully understand even in the one that worked for me why 0 was used for "true" and not 1. In my binary world we always use 0 for false an 1 for true.
So my own example would read:
"If num hatched > 0, then false" which obviously isn't the case. And I'd read your statement to read:
"If num hatched > 0, then true, else false."
So why do the 0's and 1's get switched around? Of is mine just shorthand where the first/only comma is the else statement? Did I just answer my own question lol?
Actually A your statement didn't work? Now I'm doubly confused.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Iyhamid |
last post by:
Hi
I am looking for codes to filter and apply filter to my data base using access
|
by: mattscho |
last post by:
Hi All, Trying to create a set of 3 buttons in a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly...
|
by: mattscho |
last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form.
--------------------------------------------------------------------------------
Hi All, Trying to create a set of 3 buttons in...
|
by: Fran |
last post by:
I recently tried to use code for "Use a multi-select list box to
filter a report" from Allen Browne in my database. I was able to add
the code and adapt it to my needs, however I am getting an...
|
by: Supermansteel |
last post by:
I am trying to run a Apply filter for everytime someone opens Form_CC it will only show the Test (Test_ID) they are working on. This seems to be the closest I have gotten to filtering it correctly,...
|
by: Gord |
last post by:
I'm trying to filter a report with a date in VB code.
If I type an actual date bracketed with the pound symbol (i.e. #3-Jul-08#)
I can get the filter to work. I can't seem to get it to work by...
|
by: eHaak |
last post by:
A couple years ago, I built a database in MS Access 2003. I built the form using macros in some of the command buttons, and now I’m trying to eliminate the macros and just use visual basic code. ...
|
by: dbdb |
last post by:
hi guys
need your suggestion
how can i apply filter for my date variable data type
i have a form name transaction
and i have a text box on it named : start and finish
i need to apply...
|
by: dbdb |
last post by:
Hi,
i create a chart in ms access based on my query, then i want my chart when is it open is only show value based on my criteria.
i'll try to used it in the properties apply filter using the...
|
by: Azriel928 |
last post by:
I know this is a simple function to program, but I'm a little rusty. I'm trying to set the "On Open" event on a report using a macro to apply a filter that I have saved as a query.
Can you please...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |