Equivalent to vb's causes validation?

  • Thread starter Thread starter dman
  • Start date Start date
D

dman

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.
 
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
 
Peter T said:
...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.
Regards,
Peter T

Well that is what I am trying to do. I have a canel button on the form along
with 3 combos. If the user hits the cancel button, is there a way to bypass
the Exit event of which ever combo box had focus?

Thanks.
 
I guess I'll just remove the cancel button and trap the
query close event.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top