Using an Excel Pivot Table with an Access database tutorial
Access 2003, Excel 2003, Tutorials May 23rd, 2008This is a step by step tutorial on how you can set up an Excel Pivot Table based on an Access table or query.
Step 1 - Setting up the Excel Pivot Table
First open up a new Excel worksheet and click on the Data > Pivot Table or PivotChart Report… option.
Once you have clicked on this option the following dialog box should appear, click on the External data source option and then click the Next > button.
Step 2 - Setting up the Data Source connection
A PivotTable and PivotChart Wizard - Step 2 of 3 dialog box should pop up (seen below). As we have not yet retrieved any data click on the Get Data… button.
In this example I have not yet set up a data source connection to my Access database, to do this double click on the <New Data Source> option.
Here is an example of the Data Source properties, make sure for the driver you select the Microsoft Access Driver (*.mdb) from the drop down box. After the first 2 options have been completed, click on the Connect… button.
After you have clicked the Connect… button, the ODBC Microsoft Access Setup dialog box will pop up. The first step is to click on the Select… button.
A file browser will ask you which Access database you would like to select, navigate to where your Access database (.mdb) file is and click the OK button.
You can now see that the ODBC Microsoft Access Setup dialog box lets you know the location of the Access database that you just selected. Click the OK button to continue.
You will now be brought back to the Create New Data Source dialog box, it will outline all the properties we have just setup.
The 4th step will ask you to select a table, this step is optional but as you can see from the example below I selected a table. If you decide to leave this blank, further down the track you will be asked to select which Query or Table you want to base your Pivot Table on.
When you are happy with the options, click the OK button.
There is another option to save your User ID and Password in the data source definition. I would check this box if your Access database is password protected as it will prevent any future password prompt boxes from appearing.
Now you are able to see that the Data Source has been added successfully, select the new data source that was just created and click the OK button to continue (make sure the Use the Query Wizard to create/edit queries option is checked).
Step 3 - Preparing the data for the Pivot Table
The Query Wizard steps are part of the Microsoft Query application, this sits between Excel and Access and provides a staging area for your data. As you will see from the steps below, you are able to filter or sort your data before it enters the Pivot Table.
The first step of the Query Wizard will ask you to select the Table or Query you want to base your Pivot Table on, as I selected a table in an earlier step we are only shown that table (if you left this blank in the earlier step all the available tables and queries will appear in the left pane).
Click on the table and then click the > arrow button, this will move across all the fields associated with that table, you can choose to only move over certain columns by selecting each column name and clicking the > arrow button as well. Click the Next button to move on.
Please note : If you are trying to add a Query click on the Options… button and make sure that the checkbox next to Views is checked. You should now be able to see all available Queries available in your Access database within the Available tables and columns area.
I ignored the next two steps (as the Pivot Table can do these) however these steps will allow you to:
- Filter your data before it enters the Pivot Table (good for large data sets and improving performance)
- Sort your data before it enters the Pivot Table
Here are screen shots of the steps:
Filter Data
Sort Data
Click the Next > button twice to get through these steps.
The last part of the wizard will ask you to either:
- Return Data to Microsoft Office Excel - This will close down the Query Wizard and resume finishing the Pivot Table setup.
- View data or edit query in Microsoft Query - This will open up Microsoft Query to edit your query further (editing the native SQL statement). I would suggest this if you are basing a Pivot Table on multiple tables.
- Create an OLAP Cube from this query - You can use this option to create an OLAP cube from the query.
I selected the Return Data to Microsoft Office Excel then clicked the Finish button, as I wanted to start using my Pivot Table straight away.
Step 4 - Setting up the Pivot Table
After you click the Finish button, the original dialog box will let you know that Data Fields have been retrieved, this is letting us know that all the data has been retrieved for the Pivot Table successfully. Click the Next > button to continue.
The next step is part of the standard Pivot Table wizard. It will ask you where you would like to put your Pivot Table. Select to put it in an existing worksheet starting at a certain cell or in a new sheet. Click on the Finish button to continue.
Done! Now you have a Pivot Table which is based on a table or query within Access!
Something to Remember
If the data in the Access database changes or is refreshed, to reflect the same changes in your Pivot Table you must refresh your Pivot Table. This can be done by activating the PivotTable toolbar (right click in the tool bar section at the top of Excel and select Pivot Table) and click on the ! (Refresh) button.
Your Pivot Table should now be refreshed.
If you have any questions or problems please comment.
Enjoy!



















May 23rd, 2008 at 4:20 pm
This is a great post! It worked brillantly! Thank You!
May 26th, 2008 at 10:39 pm
when i add data in the access table, and after i click on refresh on the excel pivot table, the new data is not there… how come ? thanks.
May 27th, 2008 at 9:15 am
I think I will need some more detail to work out the problem but have you done any of these before you tried to refresh the PivotTable?
1. Moved the MS Access MDB file that you have linked to another location?
2. Have you saved the file and then shut down the MS Access database, then clicked in a cell where the PivotTable resides and click the refresh button?
3. Are you sure you haven’t already put in predefined filters (page fields) on the PivotTable which will filter out your new data?
4. Are you making changes to the write table in the Access query which you are connecting to with your PivotTable?
If you are still having problems please email me at solve@jumbabox.com with the Excel and Access file zipped or with more detail about your problem and I will be more than happy to help you!
June 4th, 2008 at 4:55 am
Its very good content for me.which i m looking.thanks a lot.
June 21st, 2008 at 6:36 pm
Thanks for the content.
June 25th, 2008 at 12:49 pm
Great stuff.
July 16th, 2008 at 8:28 am
I struggled for hours on how to utilize the pivot table forms in Access and got nothing but a slow working system. Once I used this technique everything worked awesome! Thanks for the help!
July 16th, 2008 at 12:28 pm
No worries Dean!
Thanks for letting us know!
July 23rd, 2008 at 6:41 am
I have been obtaining excel pivot tables connecting with an access database, but once in the “select table” window, none query appears among the tables. I find it annoying, once the original table (production system) does not include all the fields i need, and each time require the pivot table, i need to run a maketable from the query.
Thanks in advance for your help
July 23rd, 2008 at 9:09 am
lucho,
I should of mentioned that in the post. When you are in the dialog box to select a Table, click on the Options button and make sure that the checkbox next to Views is checked, you should be able to see your query now.
*Just added this to the post as well*
Let me know if you have any problems.
August 20th, 2008 at 2:15 pm
wonderfully helpful! thank you!!!!
August 28th, 2008 at 2:42 am
I get all the way to “Finish” and get this message pop up “Syntax error in FROM clause.” Any idea what to do about this problem?
August 28th, 2008 at 8:29 am
The fields/columns within the table or query will not display. Any ideas?
September 15th, 2008 at 1:56 pm
you rock, dude!!!
October 2nd, 2008 at 6:28 am
Reply to Mari: “I get all the way to “Finish” and get this message pop up “Syntax error in FROM clause.” Any idea what to do about this problem?”
If the table containing the data in Access has any spaces in the name of the table, or strange characters, excel will not recognize it. It will pick up a table named “TABLE_MASTER” but not a table named “TABLE MASTER” or “TABLE_MASTER%”.
October 8th, 2008 at 4:44 pm
hi jeff, am getting the same error as Mari but there are no spaces or strange characters in my access table…
any other cause?
October 24th, 2008 at 4:06 am
Mari and Goddes5 - Check the SQL of your query and make sure to remove the “.mdb” from the end of the database path. I was having this error today and removing the “.mdb” fixed my problem.
Let me know if this fixes yoru issue…
October 30th, 2008 at 8:01 pm
This example will work locally because the datasource is defined on you PC and other network users cannot refresh data.
There is a simple way. When you click GET DATE just choose Microsoft Access database, and then the mdb file.
What I cannot understand is how to link to the same query but in a different mdb. database once the pivot table is created. Excel pivot wizard does not let to go back to that step. Only to the query withing the same database can be changed.
October 31st, 2008 at 3:24 am
I’m running into the same issue as Maximnl. I have tried every way imaginable to move the MDB or rename it and still get Excel’s pivot table/Query to connect to it – but with no success.
Excel seems to require that the MDB keep the exact same name in exactly the same path as originally configured, when copying it to another machine.
My VB is limited, and I’ve been trying configurations with sConn and every other method I can find, but with no success.
Any suggestions you have for changing the data source (a macro would be great, but manually is fine) would be much appreciated!
October 31st, 2008 at 10:15 am
You can not dynamically reference a file name when setting up a connection between an excel worksheet and access database… well not that I know of!
You will have to chuck the file on a shared drive or network drive and then reference the server name, if other uses have access to the share drie or network drive they can then run the pivot !
November 3rd, 2008 at 11:40 pm
Hi, After following these procedure. initially it was work perfectly but now as the database size is growing my .XLS file size also increasing. some time the system hanging. plz help me…how to reduce the file .XLS size.
November 9th, 2008 at 4:17 am
I have the same problem of increase in excel capacity because database size is increasing. Any help and suggestion would be great.
November 11th, 2008 at 3:24 am
Try this,
This helped me reducing my file size from 99 MB to 72 MB.
1. Right-click a cell in the pivot table, and click PivotTable Options.
2. On the Data tab, in the PivotTable Data section, remove the check mark from Save Source Data with File (see Figure 8-16), and then click OK.
December 13th, 2008 at 8:35 am
Do any of you know how to bypass this error: exceeds the number of unique data in the field (for the rows) field?
December 15th, 2008 at 1:27 pm
Ben,
That is a limitation of Excel it can not be bypassed.