Solved

Determine the caption of a command button

Posted on 2013-01-14
5
389 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now