Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

One-to-one in single form

Locked
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

One-to-one in single form

Unread post by forgot »

Hi guys.

Is it possible in single form edit two table with relationship one-to-one (not one-to-many) without using subform?

So I have to table Orders and Waybill. Waybill have column waybill_order_id. I could use only one table with all columns form orders and Waybill but create two only for simplicity database logic.
Now I need Browse form with all Orders and then users will chose specific order they can edit this and edit fields from Waybill table.

Thank you in advance.
Maxim.
admin
Site Admin
Posts: 2783
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 3 times

Re: One-to-one in single form

Unread post by admin »

Maxim,

The only way to do what you are asking is update the second table on After Save.

Steven
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: One-to-one in single form

Unread post by forgot »

Steven

I have to use After Save for update or insert and changes to related table. Is it I right?

What should I do to display fields from related table in the form?
Must put some code in Before Open tab, searching record and then assign table fields to form fields.
For searching I can use #recordID# hash variables but how can I assign table fields to form fields?

Maxim
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: One-to-one in single form

Unread post by massiws »

Maxim,

you can put some code in Before Browse to build a temporary table.
Have a look here: http://forums.nubuilder.cloud/viewtopic.php?f=4&t=8094

Hope this helps.
zazzium
Posts: 84
Joined: Mon Jul 04, 2011 12:52 am

Re: One-to-one in single form

Unread post by zazzium »

What should I do to display fields from related table in the form?
There is a object type Display.
In SQL to Display u can use hash variables.

example:
SQL to Display: SELECT field_name FROM table WHERE forign_key='#recordID#'
will populate the display field with 'field_name' (if the result is found)
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: One-to-one in single form

Unread post by forgot »

Hello, zazzium

Is it possible do something with Text object like you describe with Display object?

Text object has "Default Value SQL" but after I place here my SQL nothing happens.

I think it's more elegant way load necessary data from relating table, user can change them in form and then update data in After Save page.
But how can nuBuilder load data to editable field (Text field not Display field)?

Maxim
zazzium
Posts: 84
Joined: Mon Jul 04, 2011 12:52 am

Re: One-to-one in single form

Unread post by zazzium »

Maxim,

If u want the field to be editable, then the easiest way is to use subform (even for one field).

One other possibility would be.. to make Dispaly field which gets the data u need. Then add a Text field.
Hide the Display field (Display Condition: SELECT 0) and give the Dispaly value to the Text field with javascript.
After Save u can send the Text field value where u need to.
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: One-to-one in single form

Unread post by forgot »

Thank you very much for your help!
admin
Site Admin
Posts: 2783
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 3 times

Re: One-to-one in single form

Unread post by admin »

.
Locked