• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

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?
0
dsoderstrom
Asked:
dsoderstrom
1 Solution
 
IrogSintaCommented:
Me.CommandButtonName.Caption
0
 
mbizupCommented:
Try this:

Me.ActiveControl.Caption

Or this:

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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now