Valid Event

Occurs before a control loses the focus.

PROCEDURE Control.Valid

Remarks

Applies To: CheckBox | ComboBox | CommandButton | CommandGroup | EditBox | Grid | ListBox | OptionButton | OptionGroup | Spinner | TextBox

If the Valid event returns true (.T.), the control can lose focus - focus might not pass to another control. If the Valid event returns false (.F.), the control does not lose focus.

The Valid event can also return a numeric value. Returning a numeric value has one of three effects:

  • If 0 is returned, the control does not lose focus.

  • If a positive value is returned, the value specifies the number of controls the focus advances.

  • If a negative value is returned, the value specifies the number of controls the focus moves back. For example, if the Valid event returns –1, the previous control gets the focus.

You can also use the optional ObjectName parameter in the RETURN command of the Valid event to direct where focus is assigned. The object specified must be a valid Visual FoxPro object. If the specified object is disabled or cannot receive focus, then focus is assigned to the next object in the tab order. If an invalid object is specified, Visual FoxPro keeps the focus at the current object.

You can set focus to objects in the following scenarios:

  • Set focus to an object on another visible form.

  • Set focus to an object on a non-visible Page or Pageframe control.

For more information, see the RETURN command.

See Also

Reference

LostFocus Event
When Event

Other Resources

Events (Visual FoxPro)
Language Reference (Visual FoxPro)