Solved

Access Controls

Posted on 2012-03-22
4
283 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

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

896 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

16 Experts available now in Live!

Get 1:1 Help Now