Normal Topic FormResultSetTotal not counting negatives (Read 1195 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
FormResultSetTotal not counting negatives
Feb 13th, 2011 at 7:33pm
Print Post Print Post  
I'm having a small issue with a test database I'm building.

I have accounts with a subform called Pmt Data.  It's supposed to grab all the values and spit them into DBPd on the main form.  I've got some code in there to calculate compound interest, but that can be ignored.

However, I've created some test data with a positive $300, and a negative $300, and it's coming out as $600, rather than $0.  What is causing my negative amount to be counted as a positive?

Thanks!

Code
Select All
// Give Total Collected

vRecord = 1
vCount = @FormResultSetTotal("Pmt Data")
vPdHere = 0
vPdDir = 0

if vCount >0 then
{
	While vRecord <= vCount
	{
		vPdHere = @TM(vPdHere) + @TM(@FormFieldValue("Pmt Data", "PdHere", vRecord))
		vPdHereInt = @TM(vPdHereInt) + @TM(@formfieldvalue("Pmt Data", "PdHere", vRecord)) * @Exp(1+DBIntRate,((@date-(@todate(@formFieldValue("Pmt Data","LE0",vRecord))))/365))
		vPdDir = @TM(vPdDir) + @TM(@FormFieldValue("Pmt Data", "PdDir", vRecord))
		vPdDirInt = @TM(vPdDirInt) + @TM(@formfieldvalue("Pmt Data", "PdDir", vRecord)) * @Exp(1+DBIntRate,((@date-(@todate(@formFieldValue("Pmt Data","LE0",vRecord))))/365))
		vRecord = vRecord + 1
	}
	DBPd = vPdHere + vPDDir
}
 

  
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: FormResultSetTotal not counting negatives
Reply #1 - Feb 14th, 2011 at 8:12pm
Print Post Print Post  
Hello Blair,

Run the following code and I need to know what the Writeln window displays.

Code
Select All
// Give Total Collected

vRecord = 1
vCount = @FormResultSetTotal("Pmt Data")
vPdHere = 0
vPdDir = 0

if vCount >0 then
{
	While vRecord <= vCount
	{
Writeln("vPdHere Before: " + @Str(vPdHere))
Writeln("Sub Data: " + @FormFieldValue("Pmt Data", "PdHere", vRecord))
		vPdHere = @TM(vPdHere) + @TM(@FormFieldValue("Pmt Data", "PdHere", vRecord))
Writeln("vPdHere After: " + @Str(vPdHere))
		vPdHereInt = @TM(vPdHereInt) + @TM(@formfieldvalue("Pmt Data", "PdHere", vRecord)) * @Exp(1+DBIntRate,((@date-(@todate(@formFieldValue("Pmt Data","LE0",vRecord))))/365))
		vPdDir = @TM(vPdDir) + @TM(@FormFieldValue("Pmt Data", "PdDir", vRecord))
		vPdDirInt = @TM(vPdDirInt) + @TM(@formfieldvalue("Pmt Data", "PdDir", vRecord)) * @Exp(1+DBIntRate,((@date-(@todate(@formFieldValue("Pmt Data","LE0",vRecord))))/365))
		vRecord = vRecord + 1
	}
	DBPd = vPdHere + vPDDir
} 



-Ray
  

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



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: FormResultSetTotal not counting negatives
Reply #2 - Feb 17th, 2011 at 2:55am
Print Post Print Post  
Here's what I got ...

Code
Select All
vPdHere Before: 0
Sub Data: 300.000000
vPdHere After: 300
vPdHere Before: 300
Sub Data: 300.000000
vPdHere After: 600
 

  
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: FormResultSetTotal not counting negatives
Reply #3 - Feb 17th, 2011 at 9:10pm
Print Post Print Post  
Hello Blair,

I am guessing the second 300 is supposed to be a negative? I just tried this with a simple database and @FormFieldValue is able to pull negative amounts out of the subform. Not sure what you are running into.

-Ray
  

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



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: FormResultSetTotal not counting negatives
Reply #4 - May 18th, 2011 at 1:39am
Print Post Print Post  
So I'm back to fiddling with this ... and I'm trying to break down my code bit by bit through a Mass Update on a single record to play with this.

This single record has a subtable where I can clearly view 3 subrecords with the values of 4000, 2000, and 500.

Here is my Mass Update:

Code
Select All
var vRecord = 1
var vCount as int
var vPdHere = 0
var vPdDir = 0
var vLoop as int

vCount = @FormResultSetTotal("Pmt Data")
vLoop = 1

if vCount >0 then
{
	While vLoop <= vCount
	{
//		WriteLn("PD HERE" & @FormFieldValue("Pmt Data","PdHere",vLoop))
		WriteLn("PD DIR" & @FormFieldValue("Pmt Data","PdDir",vLoop))
		vLoop = vLoop +1
	}
}
 



And here is the result I'm getting back:

Code
Select All
PD DIR4000.000000
PD DIR4000.000000
PD DIR4000.000000
 



So why wouldn't my loop increment forward to get later entry values?

Thanks guys!
  
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: FormResultSetTotal not counting negatives
Reply #5 - May 18th, 2011 at 11:26am
Print Post Print Post  
Hi Blair,

I know this may not help you very much, but I built a test app and ran your code from mass update and a cmd button and it worked just fine.

Brandon

  
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: FormResultSetTotal not counting negatives
Reply #6 - May 18th, 2011 at 2:04pm
Print Post Print Post  
Hello Blair,

Is there any programming in the subform such as NotifyForm() that might be preventing Sesame from moving to the 2nd and 3rd record?

-Ray
  

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



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: FormResultSetTotal not counting negatives
Reply #7 - May 18th, 2011 at 9:00pm
Print Post Print Post  
Hey Ray!

You are on the money, as usual ... I had a NotifyForm(1) in my subform code ... I took it out and it worked like a charm!

Thanks
Blair
  
Back to top
IP Logged