Solved

Access Controls

Posted on 2012-03-22
4
279 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)
Comment Utility
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
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
1
0
 
LVL 27

Author Closing Comment

by:Lukasz Chmielewski
Comment Utility
That's it, thanks a lot !
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

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…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
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 …

743 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

13 Experts available now in Live!

Get 1:1 Help Now