How to track ActiveControl.Name when switching records in form with multiple subforms

  • Thread starter Thread starter figaro
  • Start date Start date
F

figaro

I need to have a global variable always contain the name of the
current form field. This bit of code is attached to the GotFocus
event of all fields and the Enter event of all subforms:

gxCurrentField = Me.ActiveControl.Name

However it doesn't work properly when changing records in a subform.
My parent form contains two subforms in a many-to-many relationship.
The above variable usually ends up containing the name of the first
field in the second subform when switching records in the first
subform.

How to correctly code this? Or is there some native variable I'm not
aware of? I'm using Access 2003.

Hope you can help. TIA.
 
It sounds like you are declaring the variable in the form. You should
declare it in the declarations section of a public module. I usually have a
module that I name Declarations to declare all of my public variable.

God Bless,

Mark A. Sam
 
Thanks for your reply, Mark. I do declare the variable in a public
module, so scope isn't the problem this time.

Any other thoughts? Thanks again!
 
Back
Top