Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error that is not an error
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Error that is not an error
Miscellaneous
Thread ID:
00416277
Message ID:
00416277
Views:
47
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.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Next
Reply
Map
View

Click here to load this message in the networking platform