G Scott
asked on
Determine which control has focus/active/clicked
I have a continuous form that has 48 text boxes (2 per hour) and a total of 4 rows. I want to know how to determine which of those boxes was clicked. When you click the box it opens up a popup form with a combo box. The value of the combo box is then passed back to the box that was clicked.
Maybe you need to look at it to see what is going on. It works if I program each and every textbox, but I am trying to 'automate' it a bit better.
Thanks for taking a look. MoldChanges.accdb
P.S. I have tried something like this on a few form events: Dirty, After_Update, Current. None of those worked.
Dim strActiveCtl As String
strActiveCtl = Screen.ActiveControl.Name
MsgBox strActiveCtl
And I may need to know how to do something like Forms!FormName! & Variable. If that is possible.
Maybe you need to look at it to see what is going on. It works if I program each and every textbox, but I am trying to 'automate' it a bit better.
Thanks for taking a look. MoldChanges.accdb
P.S. I have tried something like this on a few form events: Dirty, After_Update, Current. None of those worked.
Dim strActiveCtl As String
strActiveCtl = Screen.ActiveControl.Name
MsgBox strActiveCtl
And I may need to know how to do something like Forms!FormName! & Variable. If that is possible.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. You guys pointed me in the right direction. I used a bit of:
Public Function controlName(thecontrol As String)
Dim currentControl As String
Dim currentForm As String
currentControl = Screen.ActiveControl.Name
currentForm = Screen.ActiveControl.Paren t.Name
DoCmd.OpenForm "Form1"
Forms!Form1!txtControlName = currentControl
Forms!Form1!txtCurrentForm = currentForm
Forms!Form1!txtRow = Forms!Form2(currentForm)!R ow
Where I would call that fuction by, like you said pteranodon72, putting the control name on each and every call. Tedious, but it worked. Only to find out it really isn't a valid solution after all. Guess I need to really think it all the way through.
Thanks for the help. I learned something new. :)
Public Function controlName(thecontrol As String)
Dim currentControl As String
Dim currentForm As String
currentControl = Screen.ActiveControl.Name
currentForm = Screen.ActiveControl.Paren
DoCmd.OpenForm "Form1"
Forms!Form1!txtControlName
Forms!Form1!txtCurrentForm
Forms!Form1!txtRow = Forms!Form2(currentForm)!R
Where I would call that fuction by, like you said pteranodon72, putting the control name on each and every call. Tedious, but it worked. Only to find out it really isn't a valid solution after all. Guess I need to really think it all the way through.
Thanks for the help. I learned something new. :)
ASKER
Dim strActiveCtl As String
strActiveCtl = Screen.ActiveControl.Name
MsgBox strActiveCtl