Search code examples
ms-access

Do Event Macros have a self-reference capacity like Me or This?


I'd like to have a series of buttons that after being clicked, use a macro to create a TempVar containing the caption of the button. I really don't want to have to use VBA, as everything else in the form is a macro.

At the moment, I have a macro that creates a Tempvar using this selector:

[Command5].[Caption]

However, I'd like to replace [Command5] with something Me or This. Then I could copy & paste the button without having to open each new one and update the control name.


Solution

  • You can utilize [Screen].[ActiveControl] method. Set temporary variable like-

    [Screen].[ActiveControl].[Caption]
    

    Then use that tempvar for further action. See the below screenshot for better picture.

    enter image description here