Applies ToAccess for Microsoft 365 Access 2021 Access 2019 Access 2016

Returns a Boolean value indicating whether an identifier (Visual Basic) represents an object variable.

Syntax

IsObject ( identifier )

The required identifierargument is a variable name.

Remarks

IsObject is useful only in determining whether a Variant is of VarTypevbObject. This could occur if the Variant actually references (or once referenced) an object, or if it contains Nothing.

IsObject returns True if identifier is a variable declared with object type or any valid class type, or if identifier is a Variant of VarTypevbObject, or a user-defined object; otherwise, it returns False. IsObject returns True even if the variable has been set to Nothing.

Use error trapping to be sure that an object reference is valid.

Example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the IsObject function to determine if an identifier represents an object variable. MyObject and YourObject are object variables of the same type. They are generic names used for illustration purposes only.

' Declare variables.Dim MyInt As Integer, YourObject, MyCheckDim MyObject As ObjectSet YourObject = MyObject  ' Assign an object reference.MyCheck = IsObject(YourObject)  ' Returns True.MyCheck = IsObject(MyInt)  ' Returns False.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.