How to tell what field has the focus?

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!
 
B

bcap

If me.ActiveControl.Locked = True then....

Beware of controls that don't have a Locked property e.g. command buttons!
 
S

Stuart McCall

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...
 
D

Dennis

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!
 

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.

Ask a Question

Top