I think you may need to check Me.ActiveControl.Focused too. I confess to
some confusion (10 years worth) regarding these different form/control status
indicators.
Also, If you add controls to a form at runtime rather than in the designer,
then Me.ActiveControl.Name (what the original post asked for) will be
whatever you set it to.
Also, If you add controls to a form at runtime rather than in the
designer,
then Me.ActiveControl.Name (what the original post asked for) will be
whatever you set it to.
However, Form.ActiveForm.ActiveControl is bogus. If Form.ActiveForm is
NOHTING, then you have NO way to get the active control on the top most
form. I have seen this issue before... for example if the top most
form as defined by Form.ActiveForm is NOT top of the ZORDER, aka., a
MsgBox or MessageBox is in front of the Form.ActiveForm is wrong AND if
you reference Form.ActiveForm INSIDE a Form at is TOP-MOST, it is OFTEN
set to NOTHING.
To consistently get a valid form... I had to use GetActiveWindow() and
find the matching Window HANDLE from GetActiveWIndow() to a Form native
handle. Not pretty but worked for what I needed.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.