

This property returns a reference to the object from which the currently executing macro or VBA procedure was called. If intState = acObjStateDirty + acObjStateOpen ThenĭoCmd.Close intCurrentType, strCurrentName, acSaveYesĪnother useful property, especially in error-logging, the CodeContextObject property of the Application object. IntState = SysCmd(acSysCmdGetObjectState, intCurrentType, _ If intCurrentType = acForm And strCurrentName = "Products" Then StrCurrentName = Application.CurrentObjectName IntCurrentType = Application.CurrentObjectType If these conditions are true, the form is saved and then closed. You can see how it uses CurrentObjectName and SysCmd to check the state of a particular form: The following example uses the CurrentObjectType and CurrentObjectName properties with the SysCmd function to determine if the active object is the Products form and if this form is open and has been changed but not saved. The example below appears in the help file for Access 2003. For that, you can use SysCmd acSysCmdGetObjectState, or check the IsLoaded property of the appropriate AccessObject via CurrentProject.AllXXXXX (AllForms, AllReports, and others)) or CurrentData.AllXXXXX (AllTables, AllQueries, and others). However, they don't tell you whether the current object is open, or what view it's in.

These properties will give you the name and type of the object that Access thinks is active.

This article will list a variety of them. Nevertheless, there are various ways to find out. If you are writing a general-purpose routine, you may not know in what context that routine will be called, what form or control triggered it, or what the user was doing when it happened. For example, if you are writing an event procedure, you know what object raised the event.
#Which is not a microsoft access database object code
Most often when you are writing code for an Access application, you know what object - control, form, report, etc.
