Can track control that had focus last in event of another control?

Margarita

Registered User.
Local time
Yesterday, 19:13
Joined
Aug 12, 2011
Messages
185
Hello, for the Change event of Control2 on my form, it is important to know whether the control that was last in focus was Control1. Based on this, Change of Control2 will do certain calculations. Will doing this:

PHP:
Dim prevCtl As Control
Set prevCtl = Screen.PreviousControl
If prevCtl.Name = "Control1" Then
'do something
Else
'do something else
End If

always simply set prevCtl to Control2 since it's the control that has focus right now?

Thank you.
 
Perhaps set a string variable at the form level, on arrive events of controls set the form variable to the name of the current control.

That way you know at form level what the last control to be arrived at was.

That variable can be accessed via a custom event which retrieves the last accessed control on that form. So, form B may send form A the event and know which control was last accessed on form A.
 
Perhaps set a string variable at the form level, on arrive events of controls set the form variable to the name of the current control.

That way you know at form level what the last control to be arrived at was.

That variable can be accessed via a custom event which retrieves the last accessed control on that form. So, form B may send form A the event and know which control was last accessed on form A.


I am leaning towards creating a variable too. I will set the value in the gotfocus event of Control1.
Thank you.
 
You are welcome, Margarita.
 

Users who are viewing this thread

Back
Top Bottom