Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 8th, 2008, 01:24 PM
Irina_5220 Irina_5220 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 5 Irina_5220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 0
VBA - OutputTo code issue

I have a report that needs to be exported into excel.
I can export it manually, file->export and it exports it fine. What I want to do is export it when the user clicks on a button.
I have created a form with a button "Export".
Here is the code for the button:

Private Sub cmdExport_Click()
Dim stDocName As String
stDocName = "rptClientReport"

DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS, "C:\Reports\ClientReport.xls"

End Sub

and when click the button, I get error " Run time error: 9.
Subscript out of range"
Why cant I export the report automatically, but I can do it manually???? I dont see anything wrong with the actual report.
please help

Reply With Quote
  #2  
Old May 8th, 2008, 02:19 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by Irina_5220
I have a report that needs to be exported into excel.
I can export it manually, file->export and it exports it fine. What I want to do is export it when the user clicks on a button.
I have created a form with a button "Export".
Here is the code for the button:

Private Sub cmdExport_Click()
Dim stDocName As String
stDocName = "rptClientReport"

DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS, "C:\Reports\ClientReport.xls"

End Sub

and when click the button, I get error " Run time error: 9.
Subscript out of range"
Why cant I export the report automatically, but I can do it manually???? I dont see anything wrong with the actual report.
please help

A good thing to try when you get an error like this is to Google the exact error message, in quotes. You can often find a lot of discussion of the specific error. I found a couple of references that look like they might point to the problem, which is likely to be associated with Excel, rather than Access:

http://bytes.com/forum/thread191743.html
http://msdn.microsoft.com/en-us/lib...519(VS.60).aspx
__________________
Experience is the thing you have left when everything else is gone.

Reply With Quote
  #3  
Old May 8th, 2008, 02:46 PM
Irina_5220 Irina_5220 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 5 Irina_5220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 0
OutputTo code issue

thanks for those links but I have already googled
the error and was not able to find the fix.
Again, i can manually export the report as an excel
but code gives me error.
any other ideas?

Reply With Quote
  #4  
Old May 8th, 2008, 03:44 PM
rpeare rpeare is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 467 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 7 m 47 sec
Reputation Power: 117
I'm just taking a guess here but you say you're trying to export an object named

rptClientReport

If this is actually a REPORT then you can get all kinds of errors in trying to export because a report is not meant to be exported to a datasheet, it's meant to only be exported as a (for lack of a better word) picture, a pdf, a rich text file, etc. especially if you have absolutely any special sorting/grouping, formatting, and so on. If you want to actually export data to excel you should export the QUERY or TABLE that is running the report.
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #5  
Old May 9th, 2008, 02:54 PM
Irina_5220 Irina_5220 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 5 Irina_5220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 0
it is a report and it was created the same way as the other
reports in the very same database and yet, all those other
reports export to excel via code fine. This report can be exported into excel manually with no errors, the error comes
up during the code only, that is why something is weird.
I have tried transferSpreadsheet function you are talking about and yes, it exports the query, but it exports all of the
fields in a report when i want only the ones user selects via checkboxes in a form.

thanks for your help

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > VBA - OutputTo code issue


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway