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

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

Mark A. Sam

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
 
F

figaro

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!
 

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