Normal Topic 2 subforms to calc on 1 form (Read 665 times)
jyellis
Full Member
Members
***
Offline


No personal text

Posts: 114
Location: Dallas-Fort Worth Area
Joined: May 19th, 2003
2 subforms to calc on 1 form
Apr 27th, 2007 at 11:51pm
Print Post Print Post  
I have a  Trainers Certifications DB.

Main form with static info; Trainers Name, etc

On the Main form is two subforms (Certificatons and CEs)

Subform1 (Certifications) table format  (Cert Type;Date Taken;Date Expired;CEs req'd;CEs taken; CEs left)

Subform2 (CEs) table format (CE Name;Date Taken;Units;Cert Applied)

PROBLEM:  I need the Total for the CE's Taken.  when Cert type from Subform1 = Cert Applied from Subform2 then add to the CE's taken field.   Then I just will take CEs left = CEs Req'd - CE's taken

I have posted the screenshot to my google apps folder.  If you need a visual....just send me your email address.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: 2 subforms to calc on 1 form
Reply #1 - Apr 30th, 2007 at 2:59pm
Print Post Print Post  
Hello Judy,

Let me double check that I understand you.

For each record in Subform1 you want to check and see if it has a match in subform 2 based on the comparision of Sub1->Cert Type = Sub2->Cert Applied. If it does have a match then add the Units from subform 2 for that record to the running total.

Is that correct?
Is there ever going to be more than one match? If so what should be done in that case?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
jyellis
Full Member
Members
***
Offline


No personal text

Posts: 114
Location: Dallas-Fort Worth Area
Joined: May 19th, 2003
Re: 2 subforms to calc on 1 form
Reply #2 - May 9th, 2007 at 12:16am
Print Post Print Post  
Subform 1 will have a "one to many relationship" with Subform 2

So there will be several records in subform 2 (CE Applied field) that will match with 1 record on subform 1

I need a cumulative total of units (from subform2) to one Cert Type.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: 2 subforms to calc on 1 form
Reply #3 - May 9th, 2007 at 1:58pm
Print Post Print Post  
Code
Select All
Var vCertLoop as Int
Var vCertCnt as Int
Var vCELoop as Int
Var vCECnt as Int
Var vCertType as String
Var vCEsTaken as Int

	vCertLoop = 1
	vCertCnt = @FormResultSetTotal("Certifications")
	vCECnt = @FormResultSetTotal("CEs")

	While vCertLoop <= vCertCnt
	{
		vCertType = @FormFieldValue("Certifications", "Cert Type", vCertLoop)
		vCELoop = 1
		vCEsTaken = 0
		While vCELoop <= vCECnt
		{
			If vCertType = @FormFieldValue("CEs", "Cert Applied", vCELoop) Then
			{
				vCEsTaken = vCEsTaken + @ToNumber(@FormFieldValue("CEs", "Units", vCELoop))
			}
			vCELoop = vCELoop + 1
		}
		FormFieldValue("Certifications", "CEs Taken", vCertLoop, vCEsTaken)
		FormCommit("Certifications")
		vCertLoop = vCertLoop + 1
	}
	FormCommit("")
 



Let me know if you have any questions,
-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged