473,473 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Create 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_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 1803
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...
0
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.