Is there a way to determine which control on a form currently has the focus? I see how to SetFocus for a particular control, but there does not appear to be either a HasFocus or an IsActive property for the form controls.
My form has two controls that hold the same information: an Edit control where the user to type anything and a ListBox for selecting from a series of common defaults. Whenever that information changes (when the change is complete, not halfway through the typed word), I want my vbscript code to update the other control to match, and update various other controls and related DBF tables. For the listbox I use the OnSelChange event, and I had been trying to use the OnKillFocus event for the textbox. However, if they user types something new in the Edit control and then clicks on a value in the ListBox, the OnKillFocus event (of course) runs before OnSelChange. Say user types "Drain#X" in the Edit control, then clicks on "Drain#Y" in the ListBox... The user would expect for "Drain#Y" to be the current value but "Drain#X" is used instead. In fact, "Drain#X" (the typed value) stays in the Edit control; the ListBox control now has the focus but no value is currently selected (waving the mouse up and down as I test this on my desktop causes the list to scroll).
If I could check within the OnKillFocus event's code whether the listbox is the new active control, then I could probably stop the update process before it completes. But I don't see a way of doing this. I suppose I will have to use a work around, adding OnSetFocus events to all form controls except the listbox, with code to check whether the textbox value differs from the listbox. But that will be rather tedious and I'm hoping for a simpler solution. Any ideas?