Solved

Access Controls

Posted on 2012-03-22
4
285 Views
Last Modified: 2012-03-22
Hi. I have an Access 2010 Form, on which there are plenty of controls (textboxes), let's say that their names are TB1, TB2, TB3, ..., TB50. Is there a way to know which one was clicked ?

I want to change the textbox backcolor to different one, but I don't want to place 50 functions of TB*_click event. Hope I'm clear. Please ask if not.
0
Comment
Question by:Lukasz Chmielewski
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37754170
I would recommend conditional formatting.  Select all of the textboxes at once, then click conditional formatting on the ribbon.  

In the dropdown associated with Condition1, select "Field has Focus", then set the background color you want the control to have when it gets the focus.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 37754178
Create a Function in a regular VBA module. Let's say:

Public Function mWhichControl()
    Debug.Print Screen.ActiveControl.Name    '
 'real code here

End Function

Screen.ActiveControl.Name will give you the Name property of the control
Screen.ActiveControl   by itself will give the the Value of the control


Now, Select ALL your Controls at once, the put this on the Click (Or whatever event you choose) Event - directly on the Property Sheet:

=mWhichControl()

This will call the common function ...

mx
0
 
LVL 75
ID: 37754185
1
0
 
LVL 27

Author Closing Comment

by:Lukasz Chmielewski
ID: 37754739
That's it, thanks a lot !
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

807 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