Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP7: SUM doubled

Status
Not open for further replies.

cj001

Programmer
Oct 3, 2001
145
US

My SUM is doubling. How do I stop it from doing this?

THANKS!
CJ


Below is my code (OBJECT: txtDepamt, PROCEDURE: LostFocus):

bdepamt = thisform.txtDepamt.value
SUM blkbook.deprttl TO m.adepamt
SUM(bdepamt+m.adepamt) TO m.cdepamt
CLEAR
thisform.txtdeprttl.value = m.cdepamt
 
It looks like you are using the second Sum() command for no reason.

Try just adding the two values - or I am missing (Sum)thing? :)

SUM blkbook.deprttl TO m.adepamt

THISFORM.txtdeprttl.VALUE = thisform.txtDepamt.value + m.adepamt


'We all must do the hard bits so when we get bit we know where to bite' :)
 
Thank you darrellblackhawk. That did work.
 
It doesn't work. I thought it did, but it doesn't.
Any other ideas?

THANKS!
CJ


Below is what my code looks like now.
(OBJECT: txtDepamt, PROCEDURE: LostFocus)

SUM blkbook.deprttl TO m.adepamt
CLEAR
THISFORM.txtdeprttl.VALUE = thisform.txtDepamt.value + m.adepamt
 
It is doubling before the CLEAR command.
 
cj001,

It is probably giving you exactly what you are asking for. I doubt you are encountering an unknown bug or the results do to a faulty install of VFP. According to your code m.adepamt will hold the Sum of the field deprttl in the blkbook alias. So, the thing to look at is the blkbook alias and find out why you have duplicate records in there. The SUM function is doing exactly what it should be doing, the problem is with your table/cursor. Just before the SUM statement Browse blkbook and look at it to see if it has the records you expect it to have. I'll bet you find duplicate records in there.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
I wish that were the case but I have only 4 records in the table and no deleted records.
 
Are you sure that this line is correct?
[tt]
SUM(bdepamt+m.adepamt) TO m.cdepamt
[/tt]
The SUM command is a table command. It will iterate through the table and calculate what you pass to it (in this case, bdepamt+m.adepamt) FOR EACH RECORD, adding the results. It does not look like that's what you want here.

If what you want is to add bdepamt to m.adepamt then all you need is this:
[tt]
m.cdepamt=bdepamt+m.adepamt
[/tt]
Hope that helps,

Ian
 
Hello Ian,

This line is where my problem is:
SUM blkbook.deprttl TO m.adepamt

It looks like it is being run twice. I would like away to stop it from doing this.


Thanks!
CJ
 
Thanks for help everyone. I was totaling the wrong column.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top