Normal Topic [Solved] Parent and sub forms question (Read 620 times)
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
[Solved] Parent and sub forms question
Dec 26th, 2007 at 10:13pm
Print Post Print Post  
I have a sub form "Tech Info" in my "Dispatch" form. In my sub form I have it programed to fill a field on the sub form with information from the main form, Pulling it from the parent to the sub form.
My question is can it it be programed from the parent to deliver to the sub form instead?
So if the information is changed on the parent it will change on the sub form field as well without going into the sub form again.

Thank you.
Flip

« Last Edit: Jan 4th, 2008 at 2:42am by Hammer »  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Parent and sub forms question
Reply #1 - Dec 27th, 2007 at 6:07am
Print Post Print Post  
FlipGilbert wrote on Dec 26th, 2007 at 10:13pm:
My question is can it it be programed from the parent to deliver to the sub form instead?

Yes, it can. There are two ways to do it.
1. Look into FormFieldValue.

2. Look into @XResultSetForm and XResultSetValue. (Version 2)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Parent and sub forms question
Reply #2 - Dec 27th, 2007 at 11:00pm
Print Post Print Post  
Thank you Carl,
FormFieldValue looks like the answer, but from reading the example on page 248 I am only more confused. Why get the name from the subrecord if you are going to change it? or what if there is nothing there to start with? too many questions.

I'm currently using @FormFieldValue in the subrecord and thought I understood a little but reading into it, I just got lucky.

I'm trying to get the "Company_Name" field on the Dispatch form, to the "Info" field on the Tech Info subrecord in the on element change.
If you could help explain it to me I would appreciate it.

Thanks again
flip
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Parent and sub forms question
Reply #3 - Dec 28th, 2007 at 5:18am
Print Post Print Post  
Quote:
from reading the example on page 248 I am only more confused. Why get the name from the subrecord if you are going to change it?

I think you must be refering to page 249? That example is just showing you that you can, both, read from and post to the subform records. You don't normally do both at the same time, unless you need to check an existing value before you post, or if you want to document what the value was before changing it.

If you want to post a value, you would use FormFieldValue, as opposed to @FormFieldValue.

Using the following example, if you want to post from the main form to the subform...
FormName would be the name of your subform,
Name would be the name of the element in the subform that you want to change,
Instance would be the result set number, or line item number in a table view subform, of the record you want to change,
NewVal would be the new value you want to send there.

FormFieldValue(FormName, Name, Instance, NewVal)

So, you would use something like this to post to the 1st subrecord:
FormFieldValue("Tech Info", "Info", 1, Company_Name)

If you wanted to get that info into the 2nd subrecord, you would simply change the 1 to a 2 (no quotes).

If you wanted to get that info into every subrecord, you would need to put this in a loop, and use a variable that increments with each pass, as the Instance parameter. Something like this:
For i = 1 to @FormResultSetTotal("Tech Info")
     FormFieldValue("Tech Info", "Info", i, Company_Name)
Next


One of the ways to post to only a specific subrecord, is to also use @FormFieldValue in the loop. This allows you to read what is contained in one of the other elements to help determine if the current instance is the subrecord that you want to post to. The following example will only post Company_Name to subrecords where Info is blank.
For i = 1 to @FormResultSetTotal("Tech Info")
     If @FormFieldValue("Tech Info", "Info", i) = ""
           FormFieldValue("Tech Info", "Info", i, Company_Name)
Next


And, of course, you can use multiple @FormFieldValue calls in the If-Then statement get more control over which subrecords are affected.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Parent and sub forms question
Reply #4 - Dec 28th, 2007 at 10:17pm
Print Post Print Post  
Carl,
Thank you taking your valuable time to explain this to me. It does save me from asking sillier questions further down the road.
I wish you a healthy and happy 2008 my friend.
-Flip

P.S. The loop idea is EXACTLY what I needed, and I didn't even think about it until you brought it up.
« Last Edit: Dec 29th, 2007 at 12:06am by FlipGilbert »  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged