kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
This is the code that @mikerickson gave me when the controls were on multipage forms and frames.
It didn't get me to the controls due to some reasons I can't tell.
Now my new demand is that I have removed all the multipages and frames. So the controls are placed directly on the parent form - UserForm.
What I want to achieve is to be able to identify the textbox that I will double click.
I have named the textboxes as reg1 reg2 and so on.
So when I double click reg2, my goal is to run a certain macro.
For example, I unlock reg2, change its background color and so on.
I could do it individually but the code is a bit lengthy and I am looking for a smart way to get around it.
Can someone show me how to fix that?
Code:
Public Function ReallyActiveControl(Optional Container As Object) As MSForms.Control
If Container Is Nothing Then
Set Container = Me
End If
On Error Resume Next
Set ReallyActiveControl = Container.ActiveControl
Set ReallyActiveControl = Container
On Error GoTo 0
On Error Resume Next
Do
If TypeName(ReallyActiveControl) = "MultiPage" Then
With ReallyActiveControl
Set ReallyActiveControl = .Pages(.Value)
End With
End If
Set ReallyActiveControl = ReallyActiveControl.ActiveControl
Loop Until Err
On Error Goto 0
End Function
Now my new demand is that I have removed all the multipages and frames. So the controls are placed directly on the parent form - UserForm.
What I want to achieve is to be able to identify the textbox that I will double click.
I have named the textboxes as reg1 reg2 and so on.
So when I double click reg2, my goal is to run a certain macro.
For example, I unlock reg2, change its background color and so on.
I could do it individually but the code is a bit lengthy and I am looking for a smart way to get around it.
Can someone show me how to fix that?