VB Macro Command to close MS Access application

  • Thread starter Sri via AccessMonster.com
  • Start date
S

Sri via AccessMonster.com

Hi all,

In MS Access, I have written a some VB code in a macro and named it as
"AutoExec" so that when ever the Access file is opened, this code will be
executed automatically. At the end of VB code, I included "DoCmd.Quit"
expecting that my application will quit. I open this Access file using a
"Scheduler" option available in Windows XP.

I have the following problem with my tool. A new window for MS Access is
opened at the scheduled time, running the macro code automatically and
closing the file, leaving the application open. That means I find MS Access
application opened (please note that file is closed) after the macro is
finished. Could any one of you clarify the following.

1. Will "DoCmd.Quit" command not close the application completely.

2. If not, is there a command which closes application also automatically

3. Is it possible to open this file with out making it visible to user

Thanks in advance for support

Regards
Sri
 
S

Steve Schapel

Sri,

I would normally expect DoCmd.Quit to close the application and close
Access. You did not mention the details of what the scheduler actually
does, nor the details of your macro, and I don't know how the VBA code
comes into it. Perhaps somehow you are opening 2 instances of the
application, and the DoCmd.Quit is only closing one of them. Have you
considered using a Quit action at the end of the macro itself? Also, if
you move it out of the AutoExec into a standard macro, you can run it
straight from the command line of the scheduler, using syntax such as:
"C:\Progrma Files\...\Msaccess.exe" "C:\YourFolder\YourDB.mdb" /x
NameOfMacro
 

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