Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Determine the caption of a command button

Posted on 2013-01-14
5
Medium Priority
?
401 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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 how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

926 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