You can't exit MS Office Access Now

C

ChuckW

Hi,

I have an access database that is designed to run a report and create a pdf
file. I have an autoexec macro that will open the form and print it. My
final step in the autoexec macro is to exit the application. I placed a
delay so that the database would have time to create the pdf file from the
report. If I don't have this in, it closes the program before it is written.
I wrote a module and stuck the step into my autoexec macro before the exit
step. The code is below:
------------------------------------------------------------------------------
Public Function testCDO()


Dim Finish As Single
Finish = Timer + 60
DoEvents
Do Until Timer >= Finish
Loop


End Function
-----------------------------------------------------------------
I am getting an error that says "You Can't Exit MS Office Access Now. If
your running a VB module that is using OLE or DDE, you may need to interrupt
the module. The program does generate the pdf file but I have to mannualy
click OK to exit. Can someone help?

Thanks,
 
K

Ken Warthen

Chuck,

My first guess would be to create a separate routine to Quit the Access
application and then call that routine after your Loop statement. Let me
know if it works.


Public Function testCDO()

Dim Finish As Single
Finish = Timer + 60
DoEvents
Do Until Timer >= Finish
Loop

Call subQuitApplication
End Function



Public Sub subQuitApplication()
Application.Quit
End Sub



Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top