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?
dsoderstromAsked:
Who is Participating?
 
mbizupCommented:
Try this:

Me.ActiveControl.Caption

Or this:

Me.CommandButtonName.Caption
0
 
IrogSintaCommented:
Me.CommandButtonName.Caption
0
 
Anthony BerenguelCommented:
buttonText = YOUR_FORM_NAME.YOUR_BUTTON_NAME.Caption
0
 
dsoderstromAuthor Commented:
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.
0
 
mbizupCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.