Using screen.activecontrol in Form_Current VBA Code

  • Thread starter Thread starter pgilbert11
  • Start date Start date
P

pgilbert11

HI

I am trying to use the screen.activecontrol command in the Form_current sub
in order to collect the name of the textbox the cursor was last in before the
record changed.

Everytime i try and use this command i get the error message 'Run-time error
2474. The expression you entered requires the control to be in the active
window'.

I only have the one window open and i am not running it in debug mode.
I have also tried using screen.previouscontrol but this keeps returning a
Null value.

Please help!!
Let me know if you need more details.

Thanks
Paul
 
pgilbert11 said:
I am trying to use the screen.activecontrol command in the Form_current sub
in order to collect the name of the textbox the cursor was last in before the
record changed.

Everytime i try and use this command i get the error message 'Run-time error
2474. The expression you entered requires the control to be in the active
window'.

I only have the one window open and i am not running it in debug mode.
I have also tried using screen.previouscontrol but this keeps returning a
Null value.


Whenever possible, you should use Me.ActiveControl instead
of Screen.ActiveControl.

There may also be an issue about there not being an active
control the first time the Current event is triggered (when
the form is opening). If so, try trapping and ignoring the
error.
 
Marshall Barton said:
Whenever possible, you should use Me.ActiveControl instead
of Screen.ActiveControl.

There may also be an issue about there not being an active
control the first time the Current event is triggered (when
the form is opening). If so, try trapping and ignoring the
error.

Hi

Tried changing to Me.ActiveControl and ignored the first error message when
form loaded.
When using the navigate buttons i'm still getting the same error message.

Any ideas?
 
Back
Top