Solved

Determine the caption of a command button

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

746 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

11 Experts available now in Live!

Get 1:1 Help Now