A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Report export issue



 
 
Thread Tools Display Modes
  #1  
Old May 8th, 2008, 08:45 PM posted to microsoft.public.access.reports
Irina
external usenet poster
 
Posts: 28
Default Report export issue

I have a report that I can export to excel with no problems MANUALLY,
but when I create a command button for a user to click on and export
the same report to excel using VB Code,
I get an error message: Error 9 Subscript out
of range.
the code for the button is this:
Dim stDocName As String
stDocName = "rptClientReport"
DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS,
"C:\Reports\ClientReport.xls"
Can anyone advise why this code does not work?
And yet if I go under file-export-
I can export the very same report with no issues?

please help

  #2  
Old May 9th, 2008, 05:18 PM posted to microsoft.public.access.reports
George Nicholson
external usenet poster
 
Posts: 791
Default Report export issue

Seems like that should work.

1) Question: Does C:\Reports already exist? I don't think OutputTo will
create a directory, and "subscript out of range.." and "directory not found"
could be interpreted as the same message if you squint real hard...

2) One thing you could try (for testing) is to shorten the command to:
DoCmd.OutputTo acOutputReport, stDocName
Help says that if you omit the last 2 arguments, you will be prompted for
values. You might try it and see if the error still pops. In any case it
might help you zero in on the problematic argument (assuming there's only
one).

--
HTH,
George


"Irina" wrote in message
news
I have a report that I can export to excel with no problems MANUALLY,
but when I create a command button for a user to click on and export
the same report to excel using VB Code,
I get an error message: Error 9 Subscript out
of range.
the code for the button is this:
Dim stDocName As String
stDocName = "rptClientReport"
DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS,
"C:\Reports\ClientReport.xls"
Can anyone advise why this code does not work?
And yet if I go under file-export-
I can export the very same report with no issues?

please help



  #3  
Old May 9th, 2008, 11:13 PM posted to microsoft.public.access.reports
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Report export issue

Irina,
I am interested to see if you tried it with Transfer Spreadsheet in place of
OutputTo?
Did you try it and did it work? That could give a clue to the problem you
are having.


Jeanette Cunningham -- Melbourne Victoria Australia

"Irina" wrote in message
news
I have a report that I can export to excel with no problems MANUALLY,
but when I create a command button for a user to click on and export
the same report to excel using VB Code,
I get an error message: Error 9 Subscript out
of range.
the code for the button is this:
Dim stDocName As String
stDocName = "rptClientReport"
DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS,
"C:\Reports\ClientReport.xls"
Can anyone advise why this code does not work?
And yet if I go under file-export-
I can export the very same report with no issues?

please help



 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.