Skip to main content
edit spelling error, remove tag from title
Link
ypercubeᵀᴹ
  • 98.6k
  • 13
  • 215
  • 305

Microsoft Access: Combing Combining count queries into one table row

edited tags
Link
Colin 't Hart
  • 9.4k
  • 15
  • 36
  • 44
Tweeted twitter.com/#!/StackDBAs/status/496007058723196928
Source Link

Microsoft Access: Combing count queries into one table row

I'm banging my head against the wall because I'm sure this is super easy.

I have a few queries set up that get counts for a few related tables. This is for an arcade game tracking system. The queries look at two tables and returns counts for how many of each game is in inventory

(SELECT Machine.MName, Count(Machine.Mid) AS CountOfMID
FROM Machine
GROUP BY Machine.MName
ORDER BY Machine.MName;)

and another for how many games are out for rent, again it counts the number of each game (multiple copies) that are out for rent:

(SELECT Machine.MNAME, Count(Rental.Mid) AS CountOfMID1
FROM Machine LEFT JOIN Rental ON Machine.[MID] = Rental.[MID]
GROUP BY Machine.MNAME;)

My question is how do I make a report that has the each game listed and then out to the side have the appropriate counts pulled in? Something similar to this is what I'm after:

CATEGORY --- NAME ------ INVENTORY ------ AVAILABLE ------ RENTED
Video........Frogger.........2...............1..............1.....
.............Metroid.........5...............1..............4....
Pinball......Simpsons........10..............8..............2....

I'm currently putting all of my bounded controls in the MName HEADER of my report for grouping and I just need this last piece to put these counts in the same column. I have tried using the control source for a bounded control to be a sql query just like I had in the actually saved query and it just pops up with a "enter parameter" box meaning I worded it wrong or something.

I'm wondering if I need to put the data in the "details" section of the report to tie each row in to the tables in my queries. Not sure how to do any of this and I've tried everything and googled all night.

Any help would be greatly appreciated. Pictures below:

Relationships One of the Queries Report Design View Report - Almost Done