Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

do events loop for DoCmd.OutputTo

Status
Not open for further replies.

arudeguy

IS-IT--Management
May 31, 2003
6
US
Hello,

Short version:

I'm trying to do a loop like the following:

Do While IsReportLoaded("rptReportName")
DoEvents
Loop

but after a docmd.outputto. Is there any way to check to see if docmd is still outputting a report before I start something else?

i.e:

Do While docmd.isStillWorkingOn("reportname")
do events
loop

---------------------------
Long version:
I'm not a vba guy - but was asked to see if i could figure out why we're intermittently getting the dreaded error 2486 "you cant do that now" error when running a routine that outputs about 20 reports in txt, snp, and html formats. After googling, I'm guessing it has something to do with the docmd still working on one output when another one starts?

Thus the question above.

Thanks for any suggestions!!!
 
Add a dummy 21st report output file to the end of the run (something like "completed.txt"). It doesn't need to have anything in it, just to exist in a specific folder.

At the start of the run, delete this file.
At the end of this run, create this file.

In your code that needs to check if its OK to continue, wait until this file exists (using the Dir command or FileSystemObject in VBA).

John
 
Thanks John,

so here is the code I'm running:

'html report
strOutputFile = strFile & ".htm"
DoCmd.OutputTo acOutputReport, strReportName, acFormatHTML, strOutputFile, False, strTemplateFile

'snapshot report
strOutputFile = strFile & ".snp"
DoCmd.OutputTo acOutputReport, strReportName, "Snapshot Format", strOutputFile, False

'txt report
strOutputFile = strFile & ".txt"
DoCmd.OutputTo acOutputReport, strReportName, acFormatTXT, strOutputFile, False

...
my assumption has been that sometimes the first docmd command doesn't finish prior to the 2nd one starting. Is that possible?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top