Which combobox has the focus?
Hi Daniel,
Try something like this
' In Userform1
Dim mCtrInFocus As Control
Public Property Set propHadFocus(ctr As Control)
Set mCtrInFocus = ctr
End Property
Public Property Get propHadFocus() As Control
Set propHadFocus = mCtrInFocus
End Property
Private Sub ComboBox1_Enter()
Set propHadFocus = ComboBox1
End Sub
' in Userform2 with Userform1 loaded
Private Sub CommandButton1_Click()
Dim ctl As Control
On Error Resume Next
Set ctl = UserForm1.propHadFocus
If Not ctl Is Nothing Then
MsgBox ctl.Name, , TypeName(ctl)
Else
MsgBox "can't get control"
End If
End Sub
Regards,
Peter T
"Daniel Bonallack" wrote in
message ...
I have a label on Userform A - if you click it, it opens up Userform B
Is there a way of capturing (when I click the label) which combobox had
the
focus in UserForm A?
In other words, cmbIndustry in UserForm A has the cursor flashing in it.
Then I click Label A. I would like my variable sHadFocus to be equal to
"cmbIndustry".
Is that possible?
Thanks in advance
Daniel
|