ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Equivalent to vb's causes validation? (https://www.excelbanter.com/excel-programming/404290-equivalent-vbulletins-causes-validation.html)

dman[_2_]

Equivalent to vb's causes validation?
 
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.



Peter T

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.





dman[_2_]

Equivalent to vb's causes validation?
 

"Peter T" <peter_t@discussions wrote in message
...
...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.



dman[_2_]

Equivalent to vb's causes validation?
 
I guess I'll just remove the cancel button and trap the
query close event.

Thanks.

"dman" wrote in message
...

"Peter T" <peter_t@discussions wrote in message
...
...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.






All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com