I also came upon the solution with the macro, but that by itself was not sufficient. If I did a QUIT action from the macro, a system-modal message box came up, complaining the MDB file cannot be found. This of course held back my batch.
I figured that the Microsoft exit logic was written for graphical environment, so I must have a form opening and closing. The final solution looks like this:
- use AutoExec macro, instead of the /X swith on the command line
- the AutoExec macro calls my VBA code, which does the main work
- after the work is complete, the VBA code does:
- after this, control returns from the VBA code to the macro. This probably gives time for the form to come up
- next, the AutoExec macro does
- in my_form, the "close" event has the following code:
A rather contorted way, I must admit, but it works. I guess the trick was to allow the form to fully come up, forcing a few context switches in between.