Solved

Determine the caption of a command button

Posted on 2013-01-14
5
391 Views
Last Modified: 2013-01-14
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
Comment
Question by:dsoderstrom
5 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38776477
Me.CommandButtonName.Caption
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38776478
Try this:

Me.ActiveControl.Caption

Or this:

Me.CommandButtonName.Caption
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 38776482
buttonText = YOUR_FORM_NAME.YOUR_BUTTON_NAME.Caption
0
 

Author Closing Comment

by:dsoderstrom
ID: 38776506
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38776517
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question