I have an issue that's been bugging me for a few hours now:
I have a Clear Button on my Excel userform runs a subroutine that clears all data in my XY Frame.
After running this, I want to return the focus to a textbox in the XY Frame. However, I get an error every time I try to use .SetFocus.
While messing with this, I figured out that the "ActiveControl" is still the Clear Button, and I'm wondering how to switch the ActiveControl to my XY Frame. XYFrame.Activate doesn't work.
Any ideas?
Private Sub ClearButton_Click()
ClearForm ' Run subroutine to clear out data
MsgBox (XYForm.ActiveControl) ' This shows that ActiveControl is still "ClearButton"
XYFrame.Activate ' This gives an error
XYFrame.TextBox1.SetFocus ' This gives an error
End Sub
The other maddening thing is that I can refer to the textbox value without any issues, but I just can't SetFocus on the textbox either in the subroutine or in the ClearButton sub.
XYForm.TextBox1.Visible = True 'works fine
XYForm.TextBox1.Enabled = True 'works fine
XYForm.TextBox1.Locked = False 'works fine
msgbox(XYForm.TextBox1.Value) 'works fine
XYForm.TextBox.SetFocus 'doesn't work