Solved

Transferring access report to excel...

Posted on 2006-11-15
12
154 Views
Last Modified: 2013-11-28
I have an app that records a help desk-style log into an acess database (ado).

I created a report within Access to generate the output that I want.  Now, I'd like to blend that into my app.

Within access, I can simply open the report, go to Tools/Office Links/Analyze with Excel to accomplish this, but I want to do it from my code.

The reporting feature that I currently have is designed to loop through the recordset and drop the fields into Excel.
That works fine, but I need to duplicate that reporting from the Report that I've created in Access.  I need the easiest solution possible since this code is quite old and I'm trying to talk myself out of doing this anyway... ;)

Let me know if anything else is needed to get started.
Thanx.
0
Comment
Question by:sirbounty
  • 7
  • 5
12 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Hi sirbounty,

Is this report and all its calculations based on a query?  If so, then the easiest thing to do is probably just to use
the TransferSpreadsheet method to export the query results to Excel.  That will work in just one line of code,
and it has the side benefit of making the Excel data more analysis-friendly than the report dump would be.

Regards,

Patrick
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Hi Patrick - I'm not familiar with that method, but it sounds intriguing. :^)

It looks as if the control source for the details' items are all field names from the main table...  I suppose that means it's not coming from a query?  I've really got next to zero experience with Reports in Access and find them a bit confusing, admittedly... : \
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
sirbounty,

:)

Did you create the report using the wizard?  If so, what did you select as the source for the report?  BTW,
TransferSpreadsheet works for tables too, not just queries.

Regards,

Patrick
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Probably so...I'm trying to remember how to check that...back in a moment.
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Ah - it appears that it 'is' a query... :^)
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Still around matthewspatrick?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Sorry, I'll try to check in after dinner :)
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
No rush - just wanted to make sure you were getting the notifs...  :^)
I'm out after Wednesday anyway, so it's okay if we don't resolve it this week too...
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
OK, here's the syntax, assuming you're running it from Access:


With DoCmd
    .SetWarnings False
    .TransferSpreadsheet TransferType:=acExport, TableName:="NameOfYourQuery", _
        FileName:="c:\folder\subfolder\filename.xls", HasFieldNames:=True
    .SetWarnings True
End With


Even thought the argument is called TableName, it works with both tables and queries.  If HasFieldNames
is true, then you get a header row; if false, no header.

Sorry for the long wait,

Patrick
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Don't apologize...I'll take a look at this - hopefully before I head out...
Thanx again!
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
sorry for the delay -unexpected travel...

Not running it from access - need to run it from within VB.

Any idea?
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
Comment Utility
Well, if it's an Access report, instantiate an Access.Application object, open that database,
and then do the With block above, just this time:

With AccessApp.DoCmd
...

Patrick
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now