I have a table which I need to track items that are returned for repair, so track the disposition, problems and when we received and shipped the items out.:
Table Name: RMAItems id | RMANbr | PartNbr | RecvDate | ----------------------------------------- 1 | 12345 | 456-003 | 12-21-2012 | 2 | 12345 | 434-007 | 12-21-2012 | 3 | 12346 | 422-010 | | 4 | 12347 | 421-540 | 12-21-2012 | 5 | 12347 | 460-000 | | 6 | 12348 | 459-006 | 12-26-2012 | 7 | 12349 | 439-007 | | 8 | 12349 | 435-006 | |
The ‘Recv Date’ column is the only one out of the three that can be NULL (i.e. No value). The id is the primary key (no dups) and the RMA Nbr column can have duplicates (as there can be multiple items per RMA Nbr assigned to a customer). The Recv Date column can be NULL until we mark it as received and a form fills in the date automtically via another query.
I need a query in Access 2003 (my company is poor and can’t upgrade right now) to count the amount of distinct records in the RMA Nbr column in which the Recv Date field is NULL (i.e. I need to know the amount of RMA Nbr’s that have not had all items received). If I were to run the query I need on the above database I would expect it to return 3 as there are three RMA Nbr’s that have items on them that have not been received.
I’ve tried the following queries with no success:
SELECT Count(RMANbr) FROM RMAItems WHERE RecvDate Is Null;
(returns 4)
SELECT Count(*) FROM RMAItems WHERE RecvDate Is Null;
(returns 4)
SELECT Count(*) FROM (SELECT DISTINCT RMANbr FROM RMAItems) WHERE RecvDate Is Null;
(when this query is run is pops up a dialog box with a text box and ‘RecvDate’ above the text box)
As mentioned, I’m working with MS Access 2003 on a Windows XP Pro SP3 machine.
I’ve done some Google’ing but have not come up with a query that will do what I need it to do (that’s how I came up with the subquery above that didn’t work). Any help you can provide would be super.
Thanks.
Use an approach similar to your third sample, but move the
WHEREclause into the subquery. The reason you got the parameter dialog box forRecvDateis because that field was not included in the subquerySELECTlist, so was unknown/unavailable to the parent query.