开发者

Multiple instances of same access database are open on 1 machine - problem

I'm having issues with a ms access 2007 accdb, using Windows Server 2008 task scheduler for scheduled tasks. The problem is the file that's being opened by the task scheduler is opening/closing properly, but the 'lock' file (.laccdb) remains visible after the database is closed, which is an indicator that the access db thinks it's still open. Each time a new task runs, a new instance of access is being opened. I opened the Schema to show roster of all users in the database and it's showing 3 duplicates of the server name/Admin account. Below is an example of the immediate window in access:

COMPUTER_NAME LOGIN_NAME CONNECTED SUSPECT_STATE SERVER Admin True Null SERVER Admin True Null SERVER Admin True Null

I'm hoping someone else has had thi开发者_Python百科s problem and knows 1) How to easily close all the open instances of access and 2) how to prevent this from occuring when running a task. I have "Do not start a new instance" set under the task's 'settings' tab, but this is irrelevant b/c none of the tasks were running simultaneously. Thanks in advance for any assistance.


To close all open Access instances (you can't run this from Access because you can't guarantee that the running instance will be the last reference you retrieve):

Sub CloseAllAccessInstances()
    Dim acc As Access.Application

    Do
        Set acc = GetObject(, "Access.Application")

        If IsNull(acc) Then Exit Do

        acc.Quit
    Loop
End Sub

After you run the above, check the task manager. If you see msaccess.exe, then you most likely have a circular object reference. This will prevent Access from closing. For more information, have a look at http://msdn.microsoft.com/en-us/library/aa716190(VS.60).aspx.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜