472,354 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Counting Records Retrieved through Queries...

Hello,

Hope this is the right place for this...

I am creating a testing database for components as they come off a
production line.

My reports need to select faults that are found, as well as pass or
fails dependent on a batch number.

I've got this part working fine, the problems start when I want to
total up the records being displayed by batch number.

I need to count up the passes and fails, and have been using this
method in the text field that displays the number on the report:

Passes: =DCount("Pass_Fail","Faults","Pass_Fail = -1")

Fails: =DCount("Pass_Fail","Faults","Pass_Fail = 0")

The table that this data is retrieved from is called 'Faults', and now
I find that the above statement is counting all records in the table,
not just the queried ones.

I have tried changing the 'Faults' bit to 'Pass_Fail_Test' which is my
query name, but then I just get errors and nothing more :(

Any help would be much appreicated :)

Chris.

Nov 13 '05 #1
5 1742
Rog
Is Pass_Fail a Yes/No field? In that case it should work. I tried it
and it works for me.

Nov 13 '05 #2
Yes it is a yes/no field..its really odd and highly frustrating!

Nov 13 '05 #3

ch****@cemgraft.co.uk wrote:
Yes it is a yes/no field..its really odd and highly frustrating!


It's working exactly as it should if you're describing it correctly.
Your DCount statements refer to your table ('Faults') and will count
all the records from Faults regardless of what query or table your
report is based on (i.e., what the RecordSource of your report is).
You were on the right track by replacing the table name 'Faults' with
the name of your query. Be sure that you include the field which you
want to count (i.e. the first parameter in your DCount function) in
your query and be sure to include the fields which are part of your
DCount criteria in your query as well. Look up the DCount function in
Help and look at the 'expr' and 'criteria' parameters for more
information.

HTH,
Bruce

Nov 13 '05 #4
Chris,
DCount? Really? Go learn some SQL, it will improve your sex life.
Ok, let's assume a table called FAULT_FACT_TBL. Your table isn't named
this, but work with me. A simple case:
"SELECT COUNT(*) AS PASS_COUNT FROM FAULT_FACT_TBL WHERE PASS_FAIL = -1
GROUP BY BATCH_NO;"

This counts all the passes. Helpful, but we don't know how many failed with
just this. So, let's run this as a seperate query:

"SELECT COUNT(*) AS FAIL_COUNT FROM FAULT_FACT_TBL WHERE PASS_FAIL = 0 GROUP
BY BATCH_NO;"

Now we know in seperate queries how many passed and how many failed. But
our boss wants to see it on one result. Crap. The only thing we are sure
of is that SQL has this reputation as being able to present data pretty much
any way our PHB (Pointy Haired Boss, see www.dilbert.com) wants it. So,
there's gotta be a way, right. Right. A little slight of hand by using
aliases to name our views in our result and a join and we get our "Atta
Boy.":

"SELECT PASS_COUNT_VW.PASS_COUNT, FAIL_COUNT_VW.FAIL_COUNT FROM (SELECT
COUNT(*) AS PASS_COUNT FROM FAULT_FACT_TBL WHERE PASS_FAIL = -1 GROUP BY
BATCH_NO) AS PASS_COUNT_VW INNER JOIN (SELECT COUNT(*) AS FAIL_COUNT FROM
FAULT_FACT_TBL WHERE PASS_FAIL = 0 GROUP BY BATCH_NO) AS FAIL_COUNT_VW ON
PASS_COUNT_VW.BATCH_NO = FAIL_COUNT_VW.BATCH_NO;"

Now, I may be way off base and misread your e-mail. But hopefully I
understood and if I did, the above SQL should do what you want.
--
Alan Webb
kn*******@SPAMhotmail.com
"It's not IT, it's IS

<ch****@cemgraft.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello,

Hope this is the right place for this...

I am creating a testing database for components as they come off a
production line.

My reports need to select faults that are found, as well as pass or
fails dependent on a batch number.

I've got this part working fine, the problems start when I want to
total up the records being displayed by batch number.

I need to count up the passes and fails, and have been using this
method in the text field that displays the number on the report:

Passes: =DCount("Pass_Fail","Faults","Pass_Fail = -1")

Fails: =DCount("Pass_Fail","Faults","Pass_Fail = 0")

The table that this data is retrieved from is called 'Faults', and now
I find that the above statement is counting all records in the table,
not just the queried ones.

I have tried changing the 'Faults' bit to 'Pass_Fail_Test' which is my
query name, but then I just get errors and nothing more :(

Any help would be much appreicated :)

Chris.

Nov 13 '05 #5
Thanks for the responses, turned out it had something to do with dcount
not liking records after it had been filtered with a parameter, in this
case the Batch Number..

So with a little SQL and some messing about its working now!

Now for my next little problem, which doesnt belong in this forum so
I'll put it in the right one.

Thanks again,

Chris.

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chad Reid | last post by:
Hello, I have a bit of code that obviously doesn't work, but I need help creating a query that would have the same effect as if this query was working. SELECT * FROM (SELECT Count(*) AS...
1
by: Bill Agee | last post by:
I would like to number the records in a query. If I have 10 records, is there a way to assign numbers 1 - 10 to those records?
2
by: ethoemmes | last post by:
I was trying to improve the performance of a database i use for analysing data from our finance system. I added some index's to some fields i sort or filter on in the underlying tables. I also made...
15
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? ...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
2
by: mattytee123 | last post by:
I have about 20 tables, of which I would like to do a union query and count of how many of each different code there is? The simplified verson of the table is structured like this. Code ...
4
by: Jerome Ranch | last post by:
Hi I have been wrestling with this issue for a while now, and my solution is not very elegant. I have a very l;rge database with data like this (>1,000, 000 records now) GrpID GEName ...
8
by: johnds | last post by:
This is my third question about eliminating accounting entries in a clinical database, yet retaining the valid record. Latest wrinkle is being able to sum the visits to the doctor, and the units of...
1
by: gara742 | last post by:
I'm using Access 2003 to try and get some industry standards coverage data summarized. I have a nifty little query already setup that counts how many times each standard clause is covered by an...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.