473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

One report to list out different queries with same fields?

3 New Member
Say I have a database with types of car driven by people living in different cities.

I made several queries to separate out the database according to city, then made queries to count out numbers of cars. So what I have now are queries those tally different car types in each city (simplified version):

LAQuery
[Total] [NumHonda] [NumToyota] [NumFord] [NumBMW]
50 5 10 15 20

NYQuery
[Total] [NumHonda] [NumToyota] [NumFord] [NumBMW]
10 1 2 3 4

SFQuery
[Total] [NumHonda] [NumToyota] [NumFord] [NumBMW]
20 2 4 6 8

What I want as result is a report that will report number of different cars driven in each city in Columnar form:

[Type of Cars] [LA] [NY] [SF]
Total 50 10 20
Honda 5 1 2
Toyota 10 2 4
Ford 15 3 6
BMW 20 4 8


Currently the only way I could figure out is to write a union query for all the fields, then report the query by itself:

Expand|Select|Wrap|Line Numbers
  1. SELECT [Total], [NumHonda], [NumToyota], [NumFord], [NumBMW]
  2. from [LAQuery]
  3. SELECT [Total], [NumHonda], [NumToyota], [NumFord], [NumBMW]
  4. from [NYQuery]
  5. SELECT [Total], [NumHonda], [NumToyota], [NumFord], [NumBMW]
  6. from [SFQuery]
  7. ORDER by [Total];
  8.  
But this code gets rather messy when you have more than 10 fields in each query (I guess it's all copy and paste, but still).

Can Access pull data straight from each query and just report it in columnar form? Or union query is the best thing I can do about this?

Another question is, if I have to do it by union query, how can I code it so it'll list records in specific orders, i.e. Always list LA, NY, SF from top to bottom instead of lowest number on top?
(In the original database the city and car names has some other info attached behind it so I can't really order just by names only.)

Thanks in advance for your help.
Dec 5 '06 #1
3 2844
NeoPa
32,579 Recognized Expert Moderator MVP
A Crosstab query may help you here.
It would probably be more sensible looking at the source data though, before being split up into separate datasets (by your other queries).
Can you give an example of your queries.
I have to say I'm not very hot on Crosstab queries but I'm sure someone will have an answer for you.
I will look when you've posted but I can't promise I can help.
Also, can you confirm that the lists of cites and makes are foreknown (So their names can be hard-coded in rather than being produced dynamically)?
Dec 5 '06 #2
iht
3 New Member
There were 2 databases originally where one has demographic info and other has make & model of car reported for each record, joined by an ID field as primary key.

2nd database has model of car reported under fields of different car makes.

I made some first queries (LA, SF, NY) separating the records according to different cities (LA only has info for ID's in LA, etc.), then based on that query I made a query to tally the numbers of a specific make.

i. e. for LAQuery I did:

Expand|Select|Wrap|Line Numbers
  1. SELECT Count([ID]) AS Total, 
  2. Sum(IIf([Honda] is not null,1,0)) AS NumHonda,
  3. Sum(IIf([Toyota] is not null,1,0)) AS NumToyota,
  4. Sum(IIf([Ford] is not null,1,0)) AS NumFord,
  5. Sum(IIf([BMW] is not null,1,0)) AS NumBMW
  6. FROM [LA];
  7.  
Cities are foreknown, unfortunately they want to be able to add car makes to the original database so it may have to be produced dynamically....

Thanks for the help.
Dec 18 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
There were 2 databases originally where one has demographic info and other has make & model of car reported for each record, joined by an ID field as primary key.

2nd database has model of car reported under fields of different car makes.

I made some first queries (LA, SF, NY) separating the records according to different cities (LA only has info for ID's in LA, etc.), then based on that query I made a query to tally the numbers of a specific make.

i. e. for LAQuery I did:

Expand|Select|Wrap|Line Numbers
  1. SELECT Count([ID]) AS Total, 
  2. Sum(IIf([Honda] is not null,1,0)) AS NumHonda,
  3. Sum(IIf([Toyota] is not null,1,0)) AS NumToyota,
  4. Sum(IIf([Ford] is not null,1,0)) AS NumFord,
  5. Sum(IIf([BMW] is not null,1,0)) AS NumBMW
  6. FROM [LA];
  7.  
Cities are foreknown, unfortunately they want to be able to add car makes to the original database so it may have to be produced dynamically....

Thanks for the help.
What NeoPa is suggesting is that if you tell us the structure of the original data then we could probably suggest a way of creating one table with all the data in it rather than separate tables for each city.

Mary
Dec 19 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7757
by: Gord | last post by:
I would like to create a summary report from the results of 11 queries (based on 2 tables). All the queries have the same format and return 3 numbers (Count, Current Year Bal, Last Year Bal.) under different conditions. When I use the Report Wizard to select multiple queries to be included in my report, I got an error msg. It says "You have chosen fields from record sources which the wizard can't connect. You may have chosen fields...
1
17685
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
3
2339
by: Grim Reaper | last post by:
I know this is probably an easy question, but I could not find/figure it out. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types together. Also, I am using a "Report Header" to show a count of how many total labels that are being printed. Now, my problem is that without the "Report Header", the spacing is perfect. But, when I add the Report Header, it gets shifted downwards and the...
8
3539
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word templates, and the queries that drive them, depending on what events a course has.
10
2585
by: john | last post by:
I have a report to print envelopes. The report is based on a query. Now I need to make 10 more queries to make different selections of addresses. Every query has the same output fields as the already existing query. I know I can copy the report and base it on another query but then I would have to make 10 extra reports. How can I use just one report for all of the queries? At the moment I use the button wizard in my forms to make buttons...
4
3831
by: Jimmy | last post by:
I have a form with a command button on it that is supposed to open up a report and use a query to populate it. DoCmd.OpenReport "rptMailingList", acViewPreview, "qryMailingListChristmas" qryMailingListChristmas sql: SELECT DISTINCTROW tblClients.BillingName, tblClients.AccountType, tblClients.BillingAddress, tblClients.Contact, tblClients.BillingCity, tblClients.BillingState, tblClients.BillingZip,
3
6543
by: wsox66 | last post by:
I am new to Access and need some help building a report. I have looked through previous posts on reports but none of them seem to answer my question completely. I am using Access 2003 and I have a database with one table. I have built ten different queries to organize run calculations on the records in the table. The problem is that the queries don't all access the same columns nor do they all return the same number of rows and columns in...
1
2286
Altius
by: Altius | last post by:
Access Version: 2003 OS: XP Pro Sorry if this is a bit long winded. First a little info about the database. This database is used to keep track of checkout information from our production department. It has three main tables that store information, the first one, that I have named "Checkout", stores the information I am querying for the two reports. It has six different fields - OrderNumber, Date, CheckedBy, BuiltBy, SerialNumber, and...
3
18722
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
0
9715
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
9595
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
10099
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
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...
1
7643
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
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
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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
3003
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.