Hot Topic (More than 10 Replies) Utterly stumped (Read 1180 times)
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Utterly stumped
Nov 1st, 2005 at 5:33am
Print Post Print Post  
Hi all,

I've been staring at this block of code now for 4+ hours, and I don't get it.

I have created a payment subtable, with the values of PdHere or PdDir to determine payments made to our office, or to our clients' office.

All I want to do is come up with a total of the payments made here and there to work out a balance.

I've liberally used WriteLn to check my results.  I've confirmed my count of the number of payment items (vCount) is correct.  However, it's repeating the first value on the subtable.  

For example, if I have three payments of $10, $50, and $5, the sum it calculates is $30 (counting three payments, but repeatedly adding the first value of $10, $10, and $10).

Can anyone see what I'm missing here?

Thanks.
Blair

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))
            vPdDir = @TM(vPdDir) + @TM(@FormFieldValue("Pmt Data", "PdDir", vRecord))
            vRecord = vRecord + 1
      }
      DBPd = vPdHere + vPDDir
}
 

  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Utterly stumped
Reply #1 - Nov 1st, 2005 at 1:08pm
Print Post Print Post  
You're not giving us enough pieces here, Blair.

Where and how are all these varables declared?

What event is this code in?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Utterly stumped
Reply #2 - Nov 1st, 2005 at 1:17pm
Print Post Print Post  
This code executes on the main form, on form entry.

On form entry, the variables are declared - vRecord, vCount are int, and vPdHere and vPdDir are double.  The subtable records I pull data from (PdHere and PdDir) are money fields.  DBPd is a money field as well.

Does any of this help?
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Utterly stumped
Reply #3 - Nov 1st, 2005 at 1:24pm
Print Post Print Post  
Run the following code on a record. Show me the WriteLn output.

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

WriteLn("vCount: " + @Str(vCount))
if vCount >0 then
{
	While vRecord <= vCount
	{
		vPdHere = @TM(vPdHere) + @TM(@FormFieldValue("Pmt Data", "PdHere", vRecord))
		vPdDir = @TM(vPdDir) + @TM(@FormFieldValue("Pmt Data", "PdDir", vRecord))
WriteLn("vRecord: " + @Str(vRecord))
WriteLn("PdHere: " + @Str(@FormFieldValue("Pmt Data", "PdHere", vRecord)))
WriteLn("PdDir: " + @Str(@FormFieldValue("Pmt Data", "PdDir", vRecord)))
WriteLn("vPdHere: " + @Str(vPdHere))
WriteLn("vPdDir: " + @Str(vPdDir))
		vRecord = vRecord + 1
	}
	DBPd = vPdHere + vPDDir
}
 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Utterly stumped
Reply #4 - Nov 1st, 2005 at 1:46pm
Print Post Print Post  
Blair,

Are you using the latest release (1.1.2)? I experienced, what seems to be exactly the same thing, way back with version 1.0.2.

See this thread:
http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=archived;action=display...

This issue was resolved with the release of 1.0.3, and I just did some testing with 1.1.2, which is still working correctly.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Utterly stumped
Reply #5 - Nov 1st, 2005 at 5:54pm
Print Post Print Post  
I'm on 1.1.2, yessirree.

Here's the WriteLn, Erika.

vCount: 6
vRecord: 1
PdHere: 50.000000
PdDir:
vPdHere: 50
vPdDir: 0
vRecord: 2
PdHere: 50.000000
PdDir:
vPdHere: 100
vPdDir: 0
vRecord: 3
PdHere: 50.000000
PdDir:
vPdHere: 150
vPdDir: 0
vRecord: 4
PdHere: 50.000000
PdDir:
vPdHere: 200
vPdDir: 0
vRecord: 5
PdHere: 50.000000
PdDir:
vPdHere: 250
vPdDir: 0
vRecord: 6
PdHere: 50.000000
PdDir:
vPdHere: 300
vPdDir: 0

And here's what the payments look like in the subtable

10/31/2005 - Pd Here $50
10/31/2005 - Pd Dir $20
10/31/2005 - Pd Dir $20
10/31/2005 - Pd Dir $20.20
10/31/2005 - Pd Dir $50
10/31/2005 - Pd Here $56.20
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
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: Utterly stumped
Reply #6 - Nov 1st, 2005 at 6:17pm
Print Post Print Post  
Blair,

Send me the app that this code is in. Be sure to include Login and password as well as the form name that this code is on.

-Ray
  

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


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Utterly stumped
Reply #7 - Nov 1st, 2005 at 6:30pm
Print Post Print Post  
Sent!

Thanks ...
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
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: Utterly stumped
Reply #8 - Nov 1st, 2005 at 7:22pm
Print Post Print Post  
Hello Blair,

In your subforms on Form Entry command you have a call to NotifyForm(1). This is prohibiting your Main Form from advancing to the next subrecord. The reason for this is because NotifyForm(1) is not just prohibit Save, it is Prohibit Save, Advance and Retreat of the current record. If you remove that line of code your other code will work fine.

-Ray
  

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


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Utterly stumped
Reply #9 - Nov 1st, 2005 at 7:29pm
Print Post Print Post  
That was pretty esoteric ... thanks Ray!

I want to set my users up to prevent alteration of previous notes.  I'll use something different there.  Thanks again!
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Utterly stumped
Reply #10 - Nov 1st, 2005 at 8:43pm
Print Post Print Post  
Blair,

I just added @FormNotifyForm, FormNotifyForm, and FormIsNotifyForm that all accept a form name (as well as the notify flag), That way you can turn things on and off for subforms from the parent. It'll be in 1.1.3.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged