Solved

Access Controls

Posted on 2012-03-22
4
284 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 - Access MVP) 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

777 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