Quote:
>Hi I have a workbook that I use to let the user open a
>database by shelling to Access, my question is after the
>user closes all the form how can I close the session of
>Access using code.
Since Excel has no way of telling when all of the forms are closed in
Access (even if you set an object reference to the Access session
rather than shelling to it [1]), I think that the best way would be to
put some code in the Form_Close events of each form in the Access
database. When the form count hits 1 (indicating that it's the last
form), then do an application.quit:
If Forms.Count = 1 Then
Application.Quit acQuitPrompt
End If
[1] Pedantry point: If you set an object reference to Access and start
it that way, Excel should be able to query the forms count to
determine how many are open. What it CAN'T (easily or practically)
know is WHEN the last one is closed, and take the necessary action to
close Access at that time. From a practical point of view, handling
that within Access itself is the better approach IMHO.
---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *