Hi Alex
> From: Alex Thurgood <[EMAIL PROTECTED]>
>
> Hi Dietmar,
>
>> also possible. But I still have to enter the "Task_ID" in the
>> "Assignments" table. Is there a way to set this automatically from the
>> main-form's "Task.ID"?
>> The Environment: OOo 2.0.4, HSQL (default) database
>
> I'd guess you'd need some macro magic to do that, because the main form
> knows nothing of the Task.id until you create it in the subform (if I've
> understood the setup correctly). You'd need, say, a button, that would
> be connected to a macro that would create a new task, thereby
> attributing a task.id (again if I've understood correctly), and then
> ...
> Of course, if I've misunderstood what it is you want, I could be
> completely wrong ;-)
>
You were not completely wrong, just partly ;-)
The Tasks are existing, now I assign a Resource (existing) to that task
(many-to-many relationship).
In this assignment, of course I can reuse the Task.ID already on display.
But your hint to the macro was fine. After some trial-and-error I came to this,
maybe not the best way, but it works:
'This sub is assigned to the event "before record Action" of the subform
Sub SetAssTaskID (oEvent as Object)
Dim dbMainFrm as Object, dbSubFrm as Object
if oEvent.Action <> 1 then exit sub ' act only on create (2=change,
3=del)
' sub is called twice, need it
from FormController
if not oEvent.Source.supportsService("com.sun.star.form.FormController")
then exit sub
dbMainFrm = oEvent.Source.Model.parent
dbSubFrm = oEvent.Source.Model.SubForm_Grid
dbSubFrm.GetByName("TaskID").BoundField.updateLong(
dbMainFrm.fmtID.CurrentValue )
End Sub
Dietmar
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]