Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
How to link 2 subforms from 2 forms
-
- Posts: 32
- Joined: Tue Jul 03, 2012 6:50 pm
How to link 2 subforms from 2 forms
Hi Steven,
I have 2 forms, F1 and F2. Each form has its own subform, F1Sub and F2Sub. There is a lookup key in F2, so I can get data from F1. I would like to have some instructions, HOW, when I input lookup key in F2, all relevant information in F1Sub, is transferred into the F2Sub, one by one.
Your answer, as well as solving problems with Greek characters, will help me to migrate an old, large system written in 'COBOL', into nuBuilder.
Thanks again,
flsd
I have 2 forms, F1 and F2. Each form has its own subform, F1Sub and F2Sub. There is a lookup key in F2, so I can get data from F1. I would like to have some instructions, HOW, when I input lookup key in F2, all relevant information in F1Sub, is transferred into the F2Sub, one by one.
Your answer, as well as solving problems with Greek characters, will help me to migrate an old, large system written in 'COBOL', into nuBuilder.
Thanks again,
flsd
Re: How to link 2 subforms from 2 forms
flsd,
See if thins link helps.. http://forums.nubuilder.cloud/viewtopic.p ... lay+object
and this from the wiki.. http://wiki.nubuilder.com/tiki-index.ph ... her_Fields
Steven
See if thins link helps.. http://forums.nubuilder.cloud/viewtopic.p ... lay+object
and this from the wiki.. http://wiki.nubuilder.com/tiki-index.ph ... her_Fields
Steven
-
- Posts: 32
- Joined: Tue Jul 03, 2012 6:50 pm
Re: How to link 2 subforms from 2 forms
Thanks, but I need to be more specific.
I would like, with doubleclick on a button, all records from F1Sub should be transferred into the subform F2Sub.
There is no direct link between F1Sub and F2Sub, so I can not use lookup key. Direct link exists between F1 and F1Sub as well between F2 and F2Sub. Also, a lookup key joins F1 and F2.
form F1
a_id pkey
a_code
a_description
subform F1Sub
b_id pkey
b_a_id link to F1
b1
b2
b3
form F2
c_id pkey
c_a_id link to F1 (lookup key)
subform F2Sub
d_id pkey
d_c_id link to F2
d0
d1
d2
d3
What I need is, with double click on c_a_id, if exists in F1, d0=d_c_id, d1=b1, d2=b2, d3=b3 (for all records in subform F1Sub.
hope to be clear
flsd
I would like, with doubleclick on a button, all records from F1Sub should be transferred into the subform F2Sub.
There is no direct link between F1Sub and F2Sub, so I can not use lookup key. Direct link exists between F1 and F1Sub as well between F2 and F2Sub. Also, a lookup key joins F1 and F2.
form F1
a_id pkey
a_code
a_description
subform F1Sub
b_id pkey
b_a_id link to F1
b1
b2
b3
form F2
c_id pkey
c_a_id link to F1 (lookup key)
subform F2Sub
d_id pkey
d_c_id link to F2
d0
d1
d2
d3
What I need is, with double click on c_a_id, if exists in F1, d0=d_c_id, d1=b1, d2=b2, d3=b3 (for all records in subform F1Sub.
hope to be clear
flsd
Re: How to link 2 subforms from 2 forms
flsd,
The way to do this with nuBuilder would be to save the new record on Form 2 straight after you have selected the lookup.
Then in After Save get the records that are in Form 1's related subform with a select statement and insert them into the table of Form 2's subform.
You might even be able to do it with 1 SQL statement.
eg.
Trying to do this with AJAX would be a massive headache and in a lot of cases, just wouldn't work.
Steven
The way to do this with nuBuilder would be to save the new record on Form 2 straight after you have selected the lookup.
Then in After Save get the records that are in Form 1's related subform with a select statement and insert them into the table of Form 2's subform.
You might even be able to do it with 1 SQL statement.
eg.
Code: Select all
INSERT INTO tbl_name2 (col_name,...) SELECT ... col_name,... FROM tbl_name1 WHERE foreign_key = '#lookup_id#'
Steven
-
- Posts: 32
- Joined: Tue Jul 03, 2012 6:50 pm
Re: How to link 2 subforms from 2 forms
Steven,
Yes, you were right, with a SELECT command I had the result I wanted.
Please, 2 more questions.
Is it possible that some fields in the main form to be read only after the first save?
Also, is it possible to avoid deletion of lines in the subform?
Thank you very much for your software, your support and of course for your time !!!
flsd
Yes, you were right, with a SELECT command I had the result I wanted.
Please, 2 more questions.
Is it possible that some fields in the main form to be read only after the first save?
Also, is it possible to avoid deletion of lines in the subform?
Thank you very much for your software, your support and of course for your time !!!
flsd
Re: How to link 2 subforms from 2 forms
flsd,
Change this in the Subform Tab.
Steven
put this in onfocus of the Objects you want readonly.Is it possible that some fields in the main form to be read only after the first save?
Code: Select all
if(document.getElementById('recordID').value != '-1'){this.readOnly = 'readonly';}
I think this is what you are asking..is it possible to avoid deletion of lines in the subform?
Change this in the Subform Tab.
Steven
You do not have the required permissions to view the files attached to this post.
-
- Posts: 32
- Joined: Tue Jul 03, 2012 6:50 pm
Re: How to link 2 subforms from 2 forms
Steven,
Deleteable works, also code works fine for text fields, not for lookup, date, list, dropdown etc.
Thanks again
flsd
Deleteable works, also code works fine for text fields, not for lookup, date, list, dropdown etc.
Thanks again
flsd
Re: How to link 2 subforms from 2 forms
flsd,
Perhaps it would be easier to do this in the JavaScript section of the form.
Steven
Perhaps it would be easier to do this in the JavaScript section of the form.
Code: Select all
function nuLoadThis()
if(document.getElementById('recordID').value != '-1'){
document.getElementById('objectid1').readOnly = 'readonly';
document.getElementById('objectid2').readOnly = 'readonly';
document.getElementById('objectid3').readOnly = 'readonly';
document.getElementById('objectid4').readOnly = 'readonly';
document.getElementById('objectid5').readOnly = 'readonly';
//--etc.
//-- do this to all the fields and buttons you want to make readonly
}
}
-
- Posts: 32
- Joined: Tue Jul 03, 2012 6:50 pm
Re: How to link 2 subforms from 2 forms
Steven,
With the code in the JavaScript section, fields become read only, but with doubleclick on the icons, eg. calendar, you can change the field values.
Thanks,
flsd
With the code in the JavaScript section, fields become read only, but with doubleclick on the icons, eg. calendar, you can change the field values.
Thanks,
flsd
Re: How to link 2 subforms from 2 forms
flsd,
These icons and buttons all have ids just like the Objects.
If you have a look at the html source you can see what they are and add them to the list to be set to read only or disable them.
Steven
These icons and buttons all have ids just like the Objects.
If you have a look at the html source you can see what they are and add them to the list to be set to read only or disable them.
Steven