Issue 60735 - forms should have "before new record" and "after new record" events
Summary: forms should have "before new record" and "after new record" events
Alias: None
Product: Base
Classification: Application
Component: code (show other issues)
Version: OOo 2.0
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2006-01-18 00:58 UTC by kieser
Modified: 2013-08-07 15:45 UTC (History)
1 user (show)

See Also:
Latest Confirmation in: ---
Developer Difficulty: ---


Note You need to log in before you can comment on or make changes to this issue.
Description kieser 2006-01-18 00:58:05 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.
Comment 1 marc.neumann 2006-01-19 15:16:51 UTC
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
Comment 2 marc.neumann 2006-01-20 09:49:03 UTC

here is the basic code snippet
Sub before_record_change(o)
	oForm = o.source
	if oForm.supportsService("") then
		msgbox "is snew record = " + oForm.isNew()
End Sub

Sub after_record_change(o)
	oForm = o.source
	if oForm.supportsService("") then
		msgbox "is new record = " + oForm.isNew()
End Sub

You can assign the macros for the events after record change and before record

By the way, I set this DEFECT to WORKSFORME now, because there is a solution for
this defect.

Bye Marc
Comment 3 kieser 2006-01-20 13:22:23 UTC
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.
Comment 4 marc.neumann 2006-04-03 11:53:34 UTC
reopen for reassign to requirements
Comment 5 marc.neumann 2006-04-03 11:54:50 UTC