473,698 Members | 2,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_F ail","Faults"," Pass_Fail = -1")

Fails: =DCount("Pass_F ail","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 1820
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.P ASS_COUNT, FAIL_COUNT_VW.F AIL_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.B ATCH_NO = FAIL_COUNT_VW.B ATCH_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*******@SPAMh otmail.com
"It's not IT, it's IS

<ch****@cemgraf t.co.uk> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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_F ail","Faults"," Pass_Fail = -1")

Fails: =DCount("Pass_F ail","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
4679
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 numMarried FROM tblClients WHERE mID = 1), (SELECT Count(*) AS numSingle FROM tblClients WHERE mID = 2), (SELECT Count(*) AS numDivorced FROM tblClients WHERE mID = 3),
1
1367
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
2120
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 a couple of other changes to the database (added and deleted queries, installed the backup wizard from Access Web and run the utility.) Now when I go into my underlying tables I only have exactly 5000 records in the tables. Has anyone ever...
15
7246
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? Thank you.
18
2936
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 employee knows anything about Access. I've searched Google Groups, and that has been a lot of help, but there are some questions that I just can't find the answer to. I'll try to take it easy on the group after this question. I have one more...
2
4341
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 Count 1234 1 2468 1 1234 1 2468 1
4
1638
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 SampleID A C 234
8
1704
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 services received. The units cannot be less than the visits, you get a least one unit per visit. Here's the problem: If a visit is wrongly coded, then a reverse entry is made as follows. PTID CODE UNITS 1 100 ...
1
4269
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 audit. In that same query a field holds a variable that tells the user looking at it which standard it's from (AS9100, CMMI, PMBOK, etc.). What I'd like the report to do is to count the number of non-zero records, but only for a given standard type....
0
8672
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9021
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.