On Thu, 27 Jan 2005 23:39:15 -0600, John Mishefske <mi************@JUNKtds.net>
wrote:
Rog wrote: I haven't tried this but you could loop until the pdf file exists,
something like:
do until Len(Dir("c:\...\directory.pdf") <> 0
loop
but give it a maximum number of loops in case something goes wrong and
the file cannot be created.
And throw in a DoEvents statement in that loop so that Access (rather,
VBA) yields to the CPU so that the OS so that it can actually do the
file writes.
Thanks Rog and John.
I did the 'do until loop' with out a counter to prevent endless looping in the
OnClose event of the report.
The pdf file is going to exist - eventually.
Apparently, as soon as the report starts to print to the pdf printer, the
report closes. There's no close command in the macro that opens the report.
And the private sub stops even thou it has not found the pdf file.
I'm not a code writer and do not understand the DoEvents function. After
looking at the help file and the example it would appear that the DoEvents is
never going to happen anyhow because the report with the code will be closed.
A not very clean work around is to open then close an unrelated report with the
code, with out the loop, after the pdf file has been saved.
Code:
Private Sub Report_Close()
Do Until Len(Dir("e:\MyData\Directory.pdf")) <> 0
Name "e:\MyData\ Directory.pdf" As "e:\MyData\ Directory " &
(Format(Date, "yymmdd" & ".pdf"))
Loop
End Sub
Chuck
---