creating a report for an access pivot table

Hello,
Could anyone advise me on how to create an access report for a pivot table
that was created using access.  

I tried using subreports but I could not export the pivot table to neither
word nor excel...

Thank you very much.

Nora

0
noorhanabbas
2/19/2010 1:20:01 PM
access.reports 4434 articles. 0 followers. Follow

3 Replies
3840 Views

Similar Articles

[PageSpeed] 27

hi Nora,

On 19.02.2010 14:20, noorhanabbas wrote:
> Could anyone advise me on how to create an access report for a pivot table
> that was created using access.
> I tried using subreports but I could not export the pivot table to neither
> word nor excel...
Do you want an Access report or an Excel export of it?

The Excel export is quite easy:

Public Sub Export()

   On Local Error Resume Next

   Dim ea As Object
   Dim es As Object
   Dim ew As Object

   Dim rsData As DAO.Recordset
   Dim rsField As DAO.Field

   Dim DisplayAlerts As Boolean
   Dim SQL As String

   Set ea = GetObject(, "Excel.Application")
   If Err.Number <> 0 Then
     Set ea = CreateObject("Excel.Application")
     ea.Visible = False
   End If

   On Local Error GoTo LocalError

   DisplayAlerts = ea.DisplayAlerts
   ea.DisplayAlerts = False

   Set ew = ea.Workbooks.Add
   ew.Sheets.Item(3).Delete
   ew.Sheets.Item(2).Delete
   Set es = ew.Sheets.Item(1)
   es.Name = "Pivot"

   SQL = "SELECT * FROM yourPivotQuery"

   Set rsData = CurrentDbC.OpenRecordset(SQL, dbOpenSnapshot)
   If Not rsData.BOF And Not rsData.EOF Then
     For Each rsField In rsData.fields
       es.Range(Chr(65 + rsField.OrdinalPosition) & "1").FormulaR1C1 = _
         rsField.Name
     Next rsField
     es.Range("A2").CopyFromRecordset rsData
   End If
   rsData.Close
   Set rsData = Nothing

   es.Columns.AutoFit
   ea.DisplayAlerts = DisplayAlerts
   ea.Visible = True

   Set es = Nothing
   Set ew = Nothing
   Set ea = Nothing

   Exit Sub

LocalError:
   MsgBox Err.Description

End Sub


mfG
--> stefan <--
0
Stefan
2/19/2010 2:50:07 PM
Hi Stefan,
Thank you very much for your prompt reply....
Does that mean that I must write VB code to be able to export an Access pivot
table report to either Excel or Word?

I thought I could use the Office Link to button instead?!

Thanks,

Nora.

Stefan Hoffmann wrote:
>hi Nora,
>
>> Could anyone advise me on how to create an access report for a pivot table
>> that was created using access.
>> I tried using subreports but I could not export the pivot table to neither
>> word nor excel...
>Do you want an Access report or an Excel export of it?
>
>The Excel export is quite easy:
>
>Public Sub Export()
>
>   On Local Error Resume Next
>
>   Dim ea As Object
>   Dim es As Object
>   Dim ew As Object
>
>   Dim rsData As DAO.Recordset
>   Dim rsField As DAO.Field
>
>   Dim DisplayAlerts As Boolean
>   Dim SQL As String
>
>   Set ea = GetObject(, "Excel.Application")
>   If Err.Number <> 0 Then
>     Set ea = CreateObject("Excel.Application")
>     ea.Visible = False
>   End If
>
>   On Local Error GoTo LocalError
>
>   DisplayAlerts = ea.DisplayAlerts
>   ea.DisplayAlerts = False
>
>   Set ew = ea.Workbooks.Add
>   ew.Sheets.Item(3).Delete
>   ew.Sheets.Item(2).Delete
>   Set es = ew.Sheets.Item(1)
>   es.Name = "Pivot"
>
>   SQL = "SELECT * FROM yourPivotQuery"
>
>   Set rsData = CurrentDbC.OpenRecordset(SQL, dbOpenSnapshot)
>   If Not rsData.BOF And Not rsData.EOF Then
>     For Each rsField In rsData.fields
>       es.Range(Chr(65 + rsField.OrdinalPosition) & "1").FormulaR1C1 = _
>         rsField.Name
>     Next rsField
>     es.Range("A2").CopyFromRecordset rsData
>   End If
>   rsData.Close
>   Set rsData = Nothing
>
>   es.Columns.AutoFit
>   ea.DisplayAlerts = DisplayAlerts
>   ea.Visible = True
>
>   Set es = Nothing
>   Set ew = Nothing
>   Set ea = Nothing
>
>   Exit Sub
>
>LocalError:
>   MsgBox Err.Description
>
>End Sub
>
>mfG
>--> stefan <--

0
noorhanabbas
2/19/2010 3:13:40 PM
hi Nora,

On 19.02.2010 16:13, noorhanabbas wrote:
> Thank you very much for your prompt reply....
> Does that mean that I must write VB code to be able to export an Access pivot
> table report to either Excel or Word?
> I thought I could use the Office Link to button instead?!
You can use it. Open the pivot view and click on the button. The 
question is:
If you need an Excel export, I would recommend the export using the code 
posted. It gives you more control over the Excel output as you may apply 
any kind of formatting to it.



mfG
--> stefan <--
0
Stefan
2/19/2010 7:04:32 PM
Reply:

Similar Artilces:

Problems with creating a newsletter
I chose the form "Newsletter - email". I have created a 3 page newsletter. Now, I have NO IDEA how to send it out as an email. I do not want to send it as an attachment. I cannot figure out which "save as" format or what I need to do so that i can email this newsletter. Is there a website that goes through how to do this? Am I correct when I say that it has to be html in order for me to send it as email? That is not one of the options. Any help you give me would be greatly appreciated. Thank you, Markis www.adreamforabetterworld.com ...

Business Portal Error-SQL server does not exist or access denied
Hi, We are running business portal 4.0 for one of our customer. It was running correctly, however, they have changed the SQL server port (previously it was set as default 1433). After that the business portal becomes very slow and while creating a new request (purchase requisition) if we open the item pop up; it is showing exception "SQL Server does not exist or access denied...." Can any body tell me how can I provide the new port number to business portal connection to the database. Thanks and Regards, Waliullah, Thanks for using the newsgroups. I have a...

What's happened to the findfirst function in Access 2010?
I have a working Access 2007 Application which is now failing miserably in 2010. It hinges on location the first available working document in a table runing the following VBA code: With Me.Recordset .FindFirst "([fld1] + [fld2]) = 0" If .NoMatch Then .FindLast "([fdl1] + [fld2]) <> 0" Exit Sub End If .... FURTHER PROCESSING ... What must I do to correct this? Go through a record by record search? End With In 2007, this works correctly, stopping at the appropriate record (approc. rec 1385 in the recordset...

PA Misc. Log Tables
Hi, How can I find the difference between Billed and Un-billed Miscelleneous Logs? Where Can I see Un-billed Misc. Logs and which tables. Hari I have a spreadsheet with the PA tables listed in it. Send an email message to charles.zarzour@intergraph.com and I will send you the spreadsheet. I do an excel spreadsheet for each Dictionary. Makes it easy to lookup tables. "Hari" wrote: > Hi, > How can I find the difference between Billed and Un-billed Miscelleneous > Logs? > Where Can I see Un-billed Misc. Logs and which tables. > > Hari > > Can I ...

open two different Access reports
Hi, I was wondering if i can get some help here. I have two different reports that i want to open when a user clicks a button to view the reports for printing. Is there any way of popping them up at the same time in VBA? Thank you in advance Associates wrote: >Hi, > >I was wondering if i can get some help here. I have two different reports >that i want to open when a user clicks a button to view the reports for >printing. Is there any way of popping them up at the same time in VBA? > >Thank you in advance Yes. Call the DoCmd.OpenReport command twic...

Sort by Credit Card Type on EDC Detail Report
What do I have to do to get my EDC Detail Report to show different credit card types, like Visa, MC or Amex. Now under Tender Type, it just shows Credit card...well...I kinda knew that. How do I fix it? add tender types for each credit card type rather than just "credit card". then z out. all transactions after this change will reflect what you want in the reports. "tl" <tl@discussions.microsoft.com> wrote in message news:A54EEC95-208C-4962-A089-84B22A67632A@microsoft.com... > What do I have to do to get my EDC Detail Report to show different credit >...

visual basic
Hi, I trying to retrieve values from a table to calculate the 14days average value of a stock closing price. However, i encounter some problem as stated beside the code as follows: Function DaysAvgs() 'Calculate the average value of a given value. Dim db As DAO.Database Dim rst As DAO.Recordset Dim varBookmark As Variant Dim numAve, numDaysAvg As Double Dim intA, intB, lngCount As Integer Set db = CurrentDb 'Open Table Set rst = db.OpenRecordset("SGX Individual Historical", dbOpenTable) rst.MoveFirst Do While Not rst.EOF intA = 1 intB = 0 varBookmark = rst.Bookmark n...

Access 2007 and Vista code problem
I am developing a database on a XP SP2 machine. On a form I have created some buttons with event procedures that run 2 queries and open a form. I sent the db to someone running Access 2007 on a Vista machine and nothing happens when she clicks the buttons and there are no messages. I know nothing about Vista so thanks in advance for any help. Tim Might be a reference problem, have them open the open a code window and click tools references. See what says missing and tell them what should be there, Add it and it should work. Duff "Tim Reid" <TimReid@discussions.micr...

VBA to creating autotext entries or quickparts in different catego
I have a VBA application that basically allows people to easily create autotext entiries, move them between machines and use them making comments on assignments. Currently it operates in EXACTLY the same way in Word 2003 and 2007 (using userforms) and I want to keep that as long as possible. You can see the application at http://emarking-assistant.baker-evans.com and either the screen image or the video demos will give you an idea of what I am doing Currently I store all the comments in a long list of autotext entries that is displayed in a field with the value of the entr...

Macro for Sharepoint List and another Table?? Same # records?
I am creating a database which we have a form made up of prepopulated data (from a sharepoint list) and also data input needed by a user (for example, comments, etc.). I have two tables: one sharepoint list that is linked to sharepoint website and another table that houses the additional user inputs [table 2]. I have linked the files based on the primary key. So, every record in my table 2 has a plus sign and it will expand and you will see the linked data from the sharepoint list. Is there a way that I can automatically create a record for every corresponding record ...

Opening pub files created with older Publisher versions #2
I have just upgraded to Publisher 2003 from 2000 and am having trouble with pub files sent to me for our chuch newsletter which is using Publisher 97 The text is not wrapping around graphics boxes. Can I fix this? I really don't want to go back to Pub 200 Thank Richard this is caused by Publisher 97 not been printer independent. Even if you went back to Publisher 2000, unless you have the identical font versions and printer driver you would have issues with formatting. It sounds like the person sending you the file has a garbage HP inkjet printer. Get them to install the HP5P laser p...

Using Access 2003 on client to see Sharepoint 2007
Testing a Sharepoint environment and I can easily manipulate and run the database from Access 2007, but when I try to use Access 2003 it wants me to save the database to a location. The Access 2003 has the compatiblity pack, but it seems to not work when I download it. So the question is using Sharepoint 2007 and posting the Access 2007 format to it, can a user go to the sharepoint site and use a 2003 Access database that has the compatibility pack and open without having to download it? -- Message posted via http://www.accessmonster.com Send check for $500.00 to: David A Jenn...

Input to custom reports
Hello, I'd like to be able to input values to a custom report like the Year. Is there any way to package a custom report and provide input to it? Every year the user has to go into the custom report and change the Year restriction. Alternatively, (this is a payroll report), is there any global variable or some other back door that I can use to get the current year in a custom report? Given the report writer may not be the ticket what would the recommendation be to create custom reports that require input? VB.NET? -- Russ Using VBA you can allow for input in the custom reports. B...

running reports from MS CRM prompt for username and password
Senario: When running a report from Microsoft CRM client it prompts for username and password. When given it's runs the report correct question: if MS CRM 3 is configured correctly is it normal that when trying to generate a report in MS CRM prompt for username and password? No, ideally it should pass the users AD credentials to the reporting IIS server (single sign on). If you were to close the browser and run a different report does it still prompt for credentials? I've noticed this does also depend on the hostname. For instance if the reporting server uses a differe...

compact database in VBA access 2007
Hello, I have recently upgrade to office 2007 from office 2003. To compact a database from within the database itself, I used the follwing code. Unfortunately it no longer works in access 2007. Is there some similar code that will work? Public Function FncCompactTheCurrentDB() CommandBars("Menu Bar"). _ Controls("Tools"). _ Controls("Database utilities"). _ Controls("Compact and repair database..."). _ accDoDefaultAction End Function Thank You, SL On Thu, 28 Jan 2010 17:34:01 -0800, SL <SL@discussions.microsoft....

Report to show Item Class Distribution Amounts
We would like to create a report, using Crystal Reports, that would show the following: dollar amount break down of the Sales Distribution accounts (COGS and Sales) per item class based on a date range. What is the most accurate way of going about this? We could only think of this method: (in short) sum the Ext Price based on SOP30300.CSLSINDX and SLSINDX and hope it matches the SOP10102 summed distribution amounts. Any advice would be appreciated. Thanks in advance. With the SLSINDX you would use the Extended Price and the CSLSINDX you would use Extended Cost. You would probably ...

Creating Text Box in Publisher 2007 Crashes the Application
Hello, we have a clean install of Publisher 2007 under Windows XP SP2, and when we try to create a text box in a document, (both an existing document and a blank document), publisher crashes. Office is fully patched. I ran Office Diagnostics from the help menu and no problems were found and the issue persists. Any thoughts on how to resolve the issue? Thanks, Syd See if selecting a different printer as default helps. How to view error signatures if an Office program experiences a serious error and quits http://support.microsoft.com/kb/289508/en-us -- Mary Sauer MSFT MVP http://of...

LDAP Write access?
My ldap server allows Write access to entries - and a few clients now support this. Any plugins available for Outlook to allow this too? Thanks None that I'm aware of. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net Subscribe to Exchange Messaging Outlook newsletter: EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM Outlook Tips: http://www.outlook...

Create Exchange mailbox from command line
I'm writing a script using dsadd and I was wondering if it's possible to create an exchange mailbox from the command line. Donovan Maybe not exactly what you want but it may help: http://www.joeware.net/win/free/tools/exchmbx.htm -- Neil Hobson Exchange MVP For Exchange news, links, and tips, check: http://www.msexchangeblog.com "Donovan Linton" <DonovanLinton@discussions.microsoft.com> wrote in message news:D9C839EF-883D-4E2E-8BE9-57782582F043@microsoft.com... > I'm writing a script using dsadd and I was wondering if it's possible to > create an ...

Creating a Macro to Delete Commas #2
I have an excel file that the size will varry. I need a macro that will check all the fields for a comma. If there is one I would like to get rid of it. Does anyone have any idea how to do this? I have no idea and I have been assigned this task. Help --- Message posted from http://www.ExcelForum.com/ No macro required. ctrl-H for find/replace. find , replace nothing (leave the replace field blank). You can of course record that within a macro if you wish. Drabbacs >-----Original Message----- >I have an excel file that the size will varry. I need a macro that will >check ...

creating a backup on 2002 for Money 98
I am helping a friend who has 98. I need to make a backup of info on my 2002 for him to use on 98. Any suggestions as to how to do this? M98 can't read any file written by M02 besides .QIF import. M02 can't write any file readable by M98 except for .QIF export. Sounds like QIF export/import is your only choice. I suspect you will find this doesn't do what you want. "Carlotte" <Carlotta41@discussions.microsoft.com> wrote in message news:015b01c3d2fa$bbf8fd60$a101280a@phx.gbl... > I am helping a friend who has 98. I need to make a > backup of info on...

MS Access 2007 code not running
I have created a brand new database in Access 2007 and linked some VB code to run on Form_Load. This code worked perfect with no problems the day I created it. Now today I opened the same form and it is not running the Form_Load code anymore (and yes it is still there, I did not delete it). I got frustrated so I copied and pasted the code to Form_Current and several On_Change events and set breakpoints at the beginning of all the events just to see if it was the Form_Load that was not triggering, but NO events are triggering my VB code. Any ideas? See this page: http://accessjunkie.com/fa...

unable to grant existing user access to TEST company
Set up test company using live company data; ran the script referenced in CustomerSource article ID#871973; can grant and remove user access in all other companies; ran grantsql 9.2; the dexsql log shows the user already has access probably because of using the other company data for the test; I can set up a new user and grant them access, existing users who already have access can view the company...but, I cannot figure out how to grant access to the TEST company to an existing user. The error popup reads "The user could not be added to one or more databases." Dynamics 9.0,...

isinteg reports configuring tstmgr failed : ecBadVersion
we have lost our mail after NAV did it's worst. have performed eseutil /p and /d as suggested elsewhere now get error from isinteg help please Update - have now sorted this thanks ...

Adding blank "separator" Rows in a Pivot Table
Does anyone know how to insert blank rows into a pivot table (say, between groupings, etc.)? There has to be a way, since some of the various table formats that come with Excel include blank rows. Double-click the field button that you want to format Click Layout Add a checkmark to Insert blank line after each item Click OK, twice Bucko wrote: > Does anyone know how to insert blank rows into a pivot table (say, > between groupings, etc.)? There has to be a way, since some of the > various table formats that come with Excel include blank rows. -- Debra Dalgleish Contextures http...