I am working with Oracle Forms 6i.
I have a multi record block. I have provided a 'New' button that the user should click when a new record creation is required. This is because there is some other function that needs to be performed when the new record is created. Specifically, on clicking the new button, the program populates the field with values read from another table. This works fine.
However, I realized, that if the user clicks on the mutli-record block just below the last record, a new record gets created. This action does not cause the logic behind the 'New' button to execute and the record is created in a manner that is not acceptable.
First question is why does the new record get created only by clicking with the mouse with the pointer below the last record? Is there a way to stop this from happening?
Thanks in advance for your help.
Instead of stopping the automatic creation oa a new record (which can also occur on other events like KEY-DOWN on the last record), you could put your creation logic into the appropiate trigger. Forms always calls the WHEN-CREATE-RECORD-trigger when it creates a new record, so put yourt logic in there and in your creation-button simple put a CREATE_RECORD;
Probably I was not able to explaing my problem.
I have a button that creates a new record when clicked. The button's trigger has the CREATE_RECORD statement.
When a new record is created, I need to copy values from the record above it. I have therefore used DUPLICATE_RECORD in my block's WHEN-NEW-RECORD-INSTANCE trigger.
I cannot use DUPLICATE-RECORD in WHEN-CREATE-RECORD trigger.
So, I am not clear about what you are suggesting.
My problem is that a new record gets created when click with my mouse pointer below the last record in the multi-record block. Why does that happen and how to prevent it?
The only chance is to set INSERT_ALLOWED at block-level to false and in your button-trigger temporarily set it to true again. The problem with this is, that you have to enable INSERT_ALLOWED again before committing, so yu have to have a PRE-COMMIT which does so and a POST-FORM-COMMIT to disable it again.