Setting data in a form from another form

I must be overlooking the obvious but I don’t see it.
I have the following situation:

   form A             form B
+-----------+       +---------+
|  table A  |>------| table B |
+-----------+       +---------+
  FK_tbl_b            PK_tbl_b

Now table A will have a FK of table B. But the record is created first in table A.
Then a PK of table B might be searched and linked to the record in table A or a new record is created in table B and that PK would be linked to table A.

So I can’t create a related record from table A and I can’t create a related record from table B.
Wich means I have to update the record in table A from table b.

All this has to be done in a method.
Servoy keeps telling me I can’t set a foundset in form A from form B.

Any pointers on how to get this working ?

Servoy Developer
Version R2 2.1.2-build 315
Java version 1.4.2-38 (Mac OS X)

One idea:

(pseudo code):

var pkID = arguments[0]
var fkID = arguments[1]

foms.tblA.controller.find()
foms.tblA.fk_id = fkID
var found = foms.tblA.controller.search()

if(found > 0)
{
   forms.tblA.pk_id = pkID
}

Hope this helps.

P.S. LOVE your ERD in ASCII characters! :D

Hi Bob,

I made your pseude code into a global method but since this method is called from form B I get the following (pseudo) error:

Error setting form foundset, Can’t set a foundset from table B into a form using table A
Can’t set a foundset from table B into a form using table A

bcusick:
P.S. LOVE your ERD in ASCII characters!

Thanks! It’s a bit of work but a picture says more then a lot of words. :)

Can you please paste the code that you’re using?

That error doesn’t make any sense. :D

I do this kind of thing all the time…

Hmmm..odd.
Now it works.

I duplicated the form I used and removed some related tabpanels on it and tested with that. That worked.
Then moving back to the original form it also works. (!!)

And now I changed your (Bob’s) code back to how I did it in the first place which is setting the value directly without using a find so it doesn’t screw up my foundset. And that works too. (!?)

Also that error message got me baffled from the start. :shock:
Makes you wonder what the Servoy developers where smoking when they coded that error handling bit (JUST KIDDING!!! :lol: ).

Anyway…seems to work now.
Thanks for thinking with me!

No problem! I’m glad you got it worked out.