Apache OpenOffice (AOO) Bugzilla – Issue 60735
forms should have "before new record" and "after new record" events
Last modified: 2013-08-07 15:45:41 UTC
For a form, especially one that has a table control on it, there should be an event that can have a macro associated with it for before a new row is inserted (e.g. the macro can return false to veto the insert or can set values in the propoased new row) as well as after the insert into the dataset (e.g. an associatd macro can add rows to other tables or do some validation checks). At the moment there are events covering dataset loading and unloading and similar, but none that handle and allow control of inserts. This is especially useful when subforms are used. Typically subforms indicate more complex data relationships and often inserts into the master dataset requires additiional actions to be triggered.
Hi Bradley, Yes, you are right these events are not available. But you can use the event "before record action" and "after record action". In the macro you can check if you are in a new record by check RowSet.isnew(). I will create a little macro and paste it here. So stay tuned. Bye Marc
Hi, here is the basic code snippet Sub before_record_change(o) oForm = o.source if oForm.supportsService("com.sun.star.form.component.Form") then msgbox "is snew record = " + oForm.isNew() endif End Sub Sub after_record_change(o) oForm = o.source if oForm.supportsService("com.sun.star.form.component.Form") then msgbox "is new record = " + oForm.isNew() endif End Sub You can assign the macros for the events after record change and before record change. By the way, I set this DEFECT to WORKSFORME now, because there is a solution for this defect. Bye Marc
Thanks for the code. That rocks. However, I would suggest that we still need the "before record action" and "after record action" events. So can you please confirm that although this bug is closed, the request is in so that we can get these events in future? The macros you have supplied are a work-around to the fact that these events are not implemented. But they really should be.
reopen for reassign to requirements
.