Table of contents
Collapse the table of content
Expand the table of content

Detect Whether an Object Is Open

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

It is often necessary to know whether a particular database object is open before you can edit the object programmatically. The following example illustrates how to use the SysCmd method with the acSysCmdGetObjectState action to determine whether a database object is open.

The example function, IsObjectLoaded, accepts two parameters. The strObjectName parameter is the name of the databse object to check for. The strObjectType parameter is an AcObjectType constant that specifies the type of database object to check for. The IsObjectLoaded function returns True if the specified databse object is open, and returns False if it is not open.

Function IsObjectLoaded(ByVal strObjectName As String, ByVal strObjectType As AcObjectType) As Boolean 

    If SysCmd(acSysCmdGetObjectState, strObjectType, strObjectName) <> 0 Then 

       ' The object is open. 
        IsObjectLoaded = True 

       ' The object is not open. 
        IsObjectLoaded = False 
    End If 

End Function
© 2018 Microsoft