How to tell what field has the focus?

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

In Access 2003, I need to generically determine what field has the focus. The
reason for that is I need to determine if that field is locked, and if so,
take a certain action. So I need something like:

If me.(current field that has the focus).Locked = True then....

Any thoughts on how to do that?

thanks a bunch!
 
If me.ActiveControl.Locked = True then....

Beware of controls that don't have a Locked property e.g. command buttons!
 
Dennis said:
In Access 2003, I need to generically determine what field has the focus.
The
reason for that is I need to determine if that field is locked, and if so,
take a certain action. So I need something like:

If me.(current field that has the focus).Locked = True then....

Any thoughts on how to do that?

thanks a bunch!

If Me.ActiveControl.Locked Then...
 
Thanks! This is for the onKeyPress event, so it won't be a command button. In
deciding whether or not an edit has been initiated for a record, if the user
types anything in a field, the flag is set. However, if the field is locked,
nothing can be entered in that field, so the flag should not be set if that's
the case. (The onKeyPress event still fires even if the field is locked, so I
needed that safeguard in the code.)

Your solution works perfectly for my application. Thanks!
 
Back
Top