outputto challenge

m0use

Registered User.
Local time
Today, 12:43
Joined
Mar 23, 2004
Messages
23
Hello,

In VBA I'm trying to export 2 reports of my dbase as snapshots to a folder where users have access to.

The code I use:

DoCmd.OutputTo acOutputReport, "whatever", acFormatSNP, "T:\whatever.snp"
DoCmd.OutputTo acOutputReport, "whatever_1", acFormatSNP, "T:\whatever_1.snp"

The problem is that the second outputto never runs.
It only executes the first one, not the second.

However when I put this code in a button script it does work.

My problem is that I do not want to press a button to achieve this, the reports should automatically be saved as snapshots each time the dbase is run.

Has anyone have the same problem with docmd.outputto..>?

Any advise is welcome,

m0use
 
Hi,

Does your second report have data in it, if there is no data in it, that may be way it's not outputting the snapshot.

John
 
Thank you for your reply.

There is always data in the reports.

And the funny thing is that when I open the dbase with "shift" and I open the form in which i have the outputto code it will also work.

So, it does work when the i put it in a button script and it does work when i "shift"-open the dbase and manually open the form with the code.

I do not get it...

(I also tried opening the reports hidden and then doing outputto but i get the same problem with the second outputto.)

Any other suggestions?
 
Hi Again,

For your information I have a similar process and my code looks like this, and I print 30 reports in this way daily automatically:

'DoCmd.OutputTo acReport, "rptMyReport1", "SnapShotFormat(*.snp)", "E:\MyLetters\rptMyReport1.snp", False, ""

My code resides in the in timer event of a progress form.

John
 
My code is in the form_open event.
But that is not the problem because it works when i manually open the form.
Strange...

As a workaround I now made a new form in which i put the second outputto and i open it as hidden after the first outputto. This seems to work, but it not the way it should be done.

Still open to suggestions.
 
Hi,

Another method you could try is to create a module with your code in it, attached that module to a macro, and call that macro from your form in the Open event, so that on opening your form the macro is automatically triggered to run the code in the module.

John
 
Putting the code into a module is how this started.
(I usually put all my custom code in modules.)
So I'm sorry to say that is not working either.

FYI, i'm using Access 2003 on WinXP Pro.

With the workaround I mentioned it runs ok for now, but I really do not like this way of programming...
 
Hi,

OK, I'm using Access 2000 and I'm not experiencing your problems, so perhaps someone with a lot more knowledge than I can help.

John
 
John,

Thank you for your suggestions and support, it is much appreciated.
I will keep on searching for a neat solution.
As soon as I find it I will update this post for others who experience the same.

So, the challenge is still open... and I still don't get it...

Thx, m0use


Edit:

Tried adding DoEvents and For...Next loop to give time to finish first outputto does not work.
Tried putting reports in Array to force second outputto to run does not work.
(Array gives no error and dbase continues without message, just skips the second outputto...)
Added MsgBox before and after the second outputto; msgbox before gives message, msgbox after does not, but dbase still continues... very very strange...
 
Last edited:
Please keep in mind that no data is loaded during the open form event. this might be the reason why you are not getting any data for the second line.
try to put in the on load event instead
 
Tinh,

Thanks for your suggestion, but this also does not seem to work.
Still searching...
 
the only thing i can think is that the first outputto HAS to complete before the second oner can execute - so maybe you could keep doing dir commands until the first snapshot appears in the target folder

sort of

while dir("snapshot1") = vbnullstring
doevents
wend

that will make sure your second outputto doesnt start until the first one has finished
 
Re: outputto challenge closed

Right on Gemma!!!

Great, this works.
Usually i just overwrite the snapshot but now i kill it and then do as you suggested with the while-loop.
Still strange that I have to do it this way, but it does not seem to slow the processing down. Hardly notice it.

Thank you very much and have a nice day,

m0use
 
well it probably only takes a fraction of a second to save the output file, before the second one can then be saved

the doevents in the middle lets access carry on doing things if anything needs doing, so it doesnt "hang" even momentarily
 
Hi folks!
I know it's an older post, but I am having some similar diffuculty. My code is supposed to loop through 5 reports, outputting each to a snapshot file. The problem is that only the first report is output, then exits the sub. The code segment in question is below.

For x = 0 To 4
newfile = "target directory" & ArrayType(SelectReportDateRange) & "\" & ArraySort(AutoExtractSort) & "\" & ArraySort(AutoExtractSort) & "_" & dtRE(x) & "_" & Format(Forms![form name]!txtDate, "mm_dd_yyyy") & ".SNP"
Debug.Print newfile 'Used to validate when stepping through code
''' The next line runs once for the first report, then exits. Why????
DoCmd.OutputTo acOutputReport, dtReport(x), acFormatSNP, newfile
' Added this line after seeing response here, but no help
While Dir(newfile) = vbNullString
w = w + 1
Wend
Next x

Any help is really appreciated.
~Jeff
 

Users who are viewing this thread

Back
Top Bottom