You can use the CodeContextObject property to determine the object in which a macro or Visual Basic code is executing.
Setting
The CodeContextObject property is set by Microsoft Access and is read-only in all views.
Remarks
The ActiveControl, ActiveDataAccessPage, ActiveDatasheet, ActiveForm, and ActiveReport properties of the Screen object always return the object that currently has the focus. The object with the focus may or may not be the object where a macro or Visual Basic code is currently running, for example, when Visual Basic code runs in the Timer event on a hidden form.