Page 1 of 1
One-to-one in single form
Posted: Mon Dec 10, 2012 6:59 pm
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.
Re: One-to-one in single form
Posted: Mon Dec 10, 2012 9:53 pm
by admin
Maxim,
The only way to do what you are asking is update the second table on After Save.
Steven
Re: One-to-one in single form
Posted: Wed Dec 12, 2012 11:42 am
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
Re: One-to-one in single form
Posted: Wed Dec 12, 2012 11:54 am
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.
Re: One-to-one in single form
Posted: Wed Dec 12, 2012 12:34 pm
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)
Re: One-to-one in single form
Posted: Thu Dec 13, 2012 8:56 am
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
Re: One-to-one in single form
Posted: Thu Dec 13, 2012 10:04 am
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.
Re: One-to-one in single form
Posted: Tue Dec 18, 2012 8:55 am
by forgot
Thank you very much for your help!
Re: One-to-one in single form
Posted: Wed Dec 19, 2012 1:30 am
by admin
.