By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

Last Active Control

P: n/a
How do you return the last Active Control when the control is on a tab
control? Screen.ActiveControl does not seem to work. Here's the
statement that my code uses.

Set ctlOld = Screen.ActiveControl

The code line work when all controls are placed on the form page
rather than a tab control. This code should pass the last active
control to the calling module. Then the following line requests the
tabindex from the control.

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> How do you return the last Active Control when the control is on a tab
control? Screen.ActiveControl does not seem to work. Here's the
statement that my code uses. Set ctlOld = Screen.ActiveControl
Just tested on a tab control:
Debug.Print Screen.ActiveControl.Name
Debug.Print Screen.PreviousControl.Name

Both returned the correct control names.
The code line work when all controls are placed on the form page
rather than a tab control. This code should pass the last active
control to the calling module. Then the following line requests the
tabindex from the control.


?? Can you post the line that doesn't work?

Peter
--
No mails please.
Nov 12 '05 #2

P: n/a
Thanks Peter for your response.

Ok, the issue did not lie with the following statement.

Set ctlOld = Screen.ActiveControl

The dilemma related to the method the code enumerated through the
controls in conjunction with the tab order. My debugging efforts
alarmed me since the screen object did not register when activating a
watch on the variable. Further research outlined that the screen
object would not register if debugging through the VBA editor's window
since the Screen object is no longer the form or control.

Does any other method or function allow you to capture the active
control or previous control AND allow one to debug and watch the
variable? This information would help me develop more complex code
where debugging becomes essential.
On Wed, 17 Sep 2003 10:31:36 +0200, Peter Doering <ne**@doering.org>
wrote:
How do you return the last Active Control when the control is on a tab
control? Screen.ActiveControl does not seem to work. Here's the
statement that my code uses.

Set ctlOld = Screen.ActiveControl


Just tested on a tab control:
Debug.Print Screen.ActiveControl.Name
Debug.Print Screen.PreviousControl.Name

Both returned the correct control names.
The code line work when all controls are placed on the form page
rather than a tab control. This code should pass the last active
control to the calling module. Then the following line requests the
tabindex from the control.


?? Can you post the line that doesn't work?

Peter

Nov 12 '05 #3

P: n/a
Robert,
Ok, the issue did not lie with the following statement. Set ctlOld = Screen.ActiveControl The dilemma related to the method the code enumerated through the
controls in conjunction with the tab order. My debugging efforts
alarmed me since the screen object did not register when activating a
watch on the variable. Further research outlined that the screen
object would not register if debugging through the VBA editor's window
since the Screen object is no longer the form or control. Does any other method or function allow you to capture the active
control or previous control AND allow one to debug and watch the
variable? This information would help me develop more complex code
where debugging becomes essential.
If debugging is the problem you can set the breakpoint _after_ this line:
Set ctlOld = Screen.ActiveControl


Then it will be executed on the right object, before changing to the code
window.

HTH - Peter

--
No mails please.
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.