Error 2012 - Cannot call SetFocus from within a When, Valid, RangeHigh or RangeLow event
How many of us have inadvertently caused this error? Perhaps it was done by calling another form (e.g. lookup form) from the Valid event of a textbox and somewhere along the way, a specific control needs focus so we call Control.SetFocus().
Some of you may have known this (you can get from my tone that I didn't until just now) that this error is slightly misleading. It implies that all SetFocus methods called from Valid events are invalid. This is not the case.
OptionGroups, CommandGroups and Commandbuttons
CAN call SetFocus within their Valid events with no errors.
Textboxes, Editboxes, Checkboxes, Listboxes and Spinners can not.
Comboboxes are an entity unto themselves. The Valid event fires twice, once when you select a value and then again when you try to leave the control. A SetFocus can be called from the value selection Valid but VFP throws the error when you try to leave the control.
You can use this information (or not < s >) as you see fit.
Cheers!
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao