View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Equivalent to vb's causes validation?

VBA controls do not have Validation event or a CausesValidation property.
The Exit event of a VBA combo gives pretty much the same functionality as
VB's validation event, in both you can set Cancel = true to prevent focus
leaving the control.

Despite those differences, I don't see how you'd handle things differently
in VB vs VBA. If you know in advance you won't need to validate then skip
the code in the Exit event. You'd have just as much opportunity to do that
as you would to change the CausesValidation flag.

However if the combo has focus you don't know until the Exit (or VB's
validate) event has completed if user pressed a cancel button. You would be
able to detect if user pressed the little X (queryClose event) or pressed
escape (combo keydown keycode = vbKeyEscape) and set a flag to abort the
Combo's exit code.

Regards,
Peter T

"dman" wrote in message
...
I am performing some validation on the Exit method of a
combo box. However, when user selects the Cancel button,
I don't wish to perform the validation.

In VB there is a button property called Causes Validation which
you can set to false.

Is there anything in VBA? Is my validation code in the right sub?

Thanks.