Bypassing the When-Validate-Item trigger

I have a text item in a block for which I wrote the When-Validate-Item
trigger to do the data validation. I have a Cancel button in the block. When
I press the Cancel button I want to close the block with out any validation. Everything is doing fine
when the entered value is the valid one in the text item. But when the
validation fails it is throwing the message box from the When-Validate-Item.

How can I make the code not to execute the when-validate-item trigger
when I press the Cancel button. For all the rest of the cases it should work.

I already have a clear_record in the When-Button-Pressed trigger of Cancel button, but the when-validate-item for the text item wil be executed when the focus leaves from the text-item. So when I press the button when-validate-item trigger is bieng raised before executing the code in the when-button-pressed for the Cancel button.

Yes, you are right, the when-validate-item trigger will fire first. Does your when-validate-item raise an error if the text item is null? If that is the problem, then move that check to the pre-insert and pre-update triggers instead. Or, you could consider changing the validation unit in your form from the default (Item) to Record, but then you give up field-by-field validation. Or, you can do what I have done, train the users to use the clear-record key when they need to cancel an action.

What you can do is, in the cancel button property set 'mouse navigable' to false. You can also have 'keyboard navigable' to false. This should take care of the message when you click on cancecl button. This is happening because, when you click on cancel button the cursor navigates to the button (so your field loses the focus) causing when-validate to fire. This can be prevented by setting the above properties.

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.