Using screen.activecontrol in Form_Current VBA Code

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
 
M

Marshall Barton

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

pgilbert11

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?
 

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