Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to use a union query in access as a data source for a pivot table
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Rob  
View profile   Translate to Translated (View Original)
 More options 23 Feb 2007, 13:53
Newsgroups: microsoft.public.excel.querydao
From: "Rob" <rsjh...@googlemail.com>
Date: 23 Feb 2007 05:53:04 -0800
Local: Fri 23 Feb 2007 13:53
Subject: How to use a union query in access as a data source for a pivot table
Dear all,

For some years I have been using MS Access to manipulate data into a
required format and then displaying it using Pivot tablesin Excel .
The thorn in my side with this approach has always been union queries
which, except in certain circumstances, will throw an error (too many
parameters.  expected n) when you try to connect using ODBC and MS
Query.  I have used the workaround that union queries are allowed if
all the fields are numbers, i.e. no text fields.

However, as of today, I have discovered a solution in Excel 2003/
Access 2003 (which possibly also works in Excel XP/Access XP but I
haven't checked) which allows you to connect directly to a union query
and display the results in a pivot table.  This is my own personal
holy grail so I thought I'd share it.

The problem with union queries is down to the MS Access ODBC driver
not dealing with them correctly, so the solution is to avoid using
ODBC.  In its place we can use OLEDB, but that throws up the problem
of which OLEDB driver to use.  The Access OLEDB driver doesn't support
union queries either BUT the Jet 4.0 OLEDB driver does.  However, in
order for the OLEDB driver to be able to see the union query we have
to dress it up in a simple select query because it ignores everything
but tables and select queries.  The final part of the problem was how
to get the data straight into a pivot table.  This bit is simple
enough just by following the instructions in XL - rather than using
the pivot table wizard, use the get external data wizard and then
select to show the results in a pivot table.

So that's the long and short of it, here is the process to link xl to
a union query:

1.  Create your union query in Access (called MyUnion for this
example)
2.  Create a select query along the lines of 'Select * from
MyUnion' (called SelectMyUnion)
3.  In Excel, select Data\Import External Data\Import Data...
4.  Select '+Connect to New Data Source.odc'
5.  From the list of data source types, select 'Other/advanced'.
Click next.
6.  From the list of providers, select 'Microsoft Jet 4.0 OLE DB
Provider'.  Click next.
7.  Click the ... button to select the Access database that contains
SelectMyUnion.
8.  Enter any details you need to log in to the database, or just
leave it blank if there aren't any.
9.  Click 'test connection' to check it's working.  If not, check your
account details and the db
10. Click OK. (you may have to wait a while for the next dialog box to
appear - not sure why)
11. Select 'SelectMyUnion' from the list of specific tables OR just
untick the box. Click Next
(note that if you untick the box, you will be prompted to select a
table whenever you use the connection)
12. Give it a filename, e.g. MyUnionQuery.odc, and anything else you
want . Click Finish.
13. If you didn't select a table in step 11, do so now.  Select
'SelectMyUnion', click OK.
14. On the import data dialog, select 'create a pivottable report'.
15. You are now magically at step 3 of the pivot table wizard where
you can carry on as normal
16. Click Finish and hey presto, there is your union query data in a
pivot table.
17. If you need to use the connection again, you can just select the
saved .odc file from the Import Data bit (step 3).

I knew there had to be a way to do it.  Hopefully this will save
someone else 4 years of mucking about!

Rob


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to use a union query in access as a data source for a pivot ta" by Kevin N
Kevin N  
View profile   Translate to Translated (View Original)
 More options 28 Mar 2007, 02:59
Newsgroups: microsoft.public.excel.querydao
From: Kevin N <Kev...@discussions.microsoft.com>
Date: Tue, 27 Mar 2007 18:59:41 -0700
Local: Wed 28 Mar 2007 02:59
Subject: RE: How to use a union query in access as a data source for a pivot ta
Rob,
This holy grail has been quest so I am really greatful for your posting.

Unfortunately when I try this the Data Connection Wizard - Select Database
and Table screen (your step 11) does not display any select queries that
select from a SQL union query!

Do you have any suggestions?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob  
View profile   Translate to Translated (View Original)
 More options 28 Mar 2007, 13:47
Newsgroups: microsoft.public.excel.querydao
From: "Rob" <rsjh...@googlemail.com>
Date: 28 Mar 2007 05:47:02 -0700
Local: Wed 28 Mar 2007 13:47
Subject: Re: How to use a union query in access as a data source for a pivot ta
On 28 Mar, 02:59, Kevin N <Kev...@discussions.microsoft.com> wrote:

unfortunately, not really.  If you have followed the instructions
above and are using XL 2003 with Access 2003 then I'm really not
sure.  I've had a look through the process again and there are no
settings I can find that would hide the queries.

Can you see the other select queries in your database that are based
on local tables?
Is the 'select query' that looks at the 'union query' a 'pass-through
query' because I'm not sure p-t queries show up.

If you give me a bit more info on your setup, I'll see what I can do.

Rob


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to use a union query in access as a data source for a pivo" by Kevin N
Kevin N  
View profile   Translate to Translated (View Original)
 More options 28 Mar 2007, 15:48
Newsgroups: microsoft.public.excel.querydao
From: Kevin N <Kev...@discussions.microsoft.com>
Date: Wed, 28 Mar 2007 07:48:04 -0700
Local: Wed 28 Mar 2007 15:48
Subject: Re: How to use a union query in access as a data source for a pivo
Thanks for your prompt response.

I am using MS Excel 2003 querying a MS Access 2003 desktop .mdb application
which is sat on a network server.

I have several select queries using a SQL union query as their data source.  
Non of these select queries are visible from the connection wizard.  Tables
and queries not associated with the SQL union query are visible.

I am currently using a make table query which I run via an event on my Excel
file to update a table prior to refreshing the Data Query on the worksheet
which is pointed at the table.  This works but is not very elegant hance my
interest in your break through. I can understand your satisfaction.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob  
View profile   Translate to Translated (View Original)
 More options 28 Mar 2007, 19:59
Newsgroups: microsoft.public.excel.querydao
From: "Rob" <rsjh...@googlemail.com>
Date: 28 Mar 2007 11:59:21 -0700
Local: Wed 28 Mar 2007 19:59
Subject: Re: How to use a union query in access as a data source for a pivo
On Mar 28, 3:48 pm, Kevin N <Kev...@discussions.microsoft.com> wrote:

hmm - that is a strange one - it sounds exactly like what I do.  From
what you write, it sounds like you have a number of 'complex' select
queries.  Have you tried doing a simple "Select * from UNION" to see
if that works?

Rob


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to use a union query in access as a data source for a pivot table" by Ray Jolly
Ray Jolly  
View profile   Translate to Translated (View Original)
 More options 29 Nov 2007, 21:55
Newsgroups: microsoft.public.excel.querydao
From: "Ray Jolly"<homel...@homeless.com>
Date: Fri, 30 Nov 2007 05:55:24 +0800
Local: Thurs 29 Nov 2007 21:55
Subject: Re:How to use a union query in access as a data source for a pivot table
YOU ARE A LIFE SAVER!!!  For the life of me, I could not figure out how to
address this until I came across your posting.  Thank you SO much.

url:http://www.ureader.com/msg/1038263.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google