Link to home
Start Free TrialLog in
Avatar of dsoderstrom
dsoderstrom

asked on

Determine the caption of a command button

When a user clicks a command button on a form in MS Access I would like to write the Form Name, command button caption, username, date and time to a file using vba.  I know how to capture everything except for the Command Button Caption.  How would I do that?
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Me.CommandButtonName.Caption
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
buttonText = YOUR_FORM_NAME.YOUR_BUTTON_NAME.Caption
Avatar of dsoderstrom
dsoderstrom

ASKER

Thank You.
I was looking for a generic piece of code that would work regardless of the command button clicked and Me.ActiveControl.caption is what I needed.
Another good one along those lines is

Me.previouscontrol

Good for command button code for determining the textbox etc the user was entering data in immediately before clicking the button.