Get the name of current control (1 Viewer)

JasperK

New member
Local time
Today, 21:54
Joined
Dec 20, 2007
Messages
7
Can somebody tell me how i can get the name of the current control?!

For example, on a form with a textfield with the name Text1:

Private sub Text1_Afterupdate()
Msgbox Text1.name
End sub

Only now i want to also to work with Text2. It is possible to do the same als in the text1 example, but i would like to know another option that is the same for all controls.

Many thanks in advance,

Jasper
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:54
Joined
Jul 9, 2003
Messages
16,331
You can get the screen active control

Dim strActiveCtl as string

strActiveCtl = Screen.ActiveControl.Name

This will return the name of the control that you pressed, you can also get the actual control itself and pass it into a control variable and work on it there.

You can also get the active form name, and even the active form as a form variable.

I have been exploring the use of these more advanced MS Access functions and also developing class modules, you can see an example which is utilized in displaying a calendar form, the calendar form can be used on a form, subform, it has a button for cancel, clear, restore, and it can also call a function on the form that called it. (the calling form) this is a free download from my web site here : you will be asked to join, if you do not wish to join, then send me an e-mail and I will send the form back to you...
 

JasperK

New member
Local time
Today, 21:54
Joined
Dec 20, 2007
Messages
7
Thanks! That's it!

Marvellous!!
 

Users who are viewing this thread

Top Bottom