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!

Summing at bottom of report

Status
Not open for further replies.

Kerbouchard

IS-IT--Management
Aug 28, 2002
145
US
I have this set up on the print button on my form. The only one that works is the one I put directly beneath the variables. The next one listed turns up as 0.00 but there is definitely data in the table. I'm sure it's something simple. Any suggestions?

PRIVATE pn_Extprice,pn_Total
SUM(quotes1.discext) while quotes1.quote=thisform.txtquote.value to pn_Total (works)
SUM(quotes1.extprice) while quotes1.quote=thisform.txtquote.value to pn_Extprice (doesn't)
 
I'm not SURE....

but you dataset needs reseting if you use a while, try changing it to a for:

Code:
PRIVATE pn_Extprice,pn_Total
SUM(quotes1.discext) for quotes1.quote=thisform.txtquote.value to pn_Total (works)
SUM(quotes1.extprice) for quotes1.quote=thisform.txtquote.value to pn_Extprice 
(doesn't)

Regards

Griff
Keep [Smile]ing
 
That did it. Thanks Griff! I really appreciate it.
 
I think Griff is correct. You should definitely use FOR instead of WHILE. I also think WHILE would work if you put GO TOP between the statements.

Jim
 
Jim

The 'Go Top' would only have worked if (by coincidence) the first record matched the selection criteria - otherwise it would simply have dropped out of the sum()



Regards

Griff
Keep [Smile]ing
 
For speed you could try...

Code:
PRIVATE pn_Extprice,pn_Total
SUM quotes1.discext, quotes1.extprice for quotes1.quote=thisform.txtquote.value to pn_Total, pn_Extprice


Regards

Griff
Keep [Smile]ing
 
For some reason this is giving the wrong totals now. This is actually kind of dangerous and if anyone has any suggestions I would REALLY apprecite it!!


PRIVATE pn_Extprice,pn_Total
SUM(quotes1.discext) for quotes1.quote=thisform.txtquote.value to pn_Total
SUM(quotes1.extprice) for quotes1.quote=thisform.txtquote.value to pn_Extprice

 
Kerbouchard,

How do you know the totals are wrong? I mean VFP is giving you exactly what you are asking for...so your code must be asking for the wrong sum or include the wrong criteria or there are records being either ruled in or ruled out based on some system/datasession setting that you are unaware of. In order to answer your question I would need to know what you got for totals, what you were expecting (was it more or less than what you got), how the relevant parts of your environment are set up, and any extraneous factors that could skew the results from what you had expected. I'm sorry this isn't an answer to your question, more my thoughts on your question...and maybe if you change the question you are asking it will lead you to the answer.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Just a guess.... Is quotes1.quote a character string? If so, try changing

quotes1.quote=thisform.txtquote.value

to

quotes1.quote==thisform.txtquote.value


Jim
 
Hi guys thanks for the response.

Just to get it to work I dropped it to one column and am still getting bizarre answers.
The column is numeric.
The code for the print button is:
PRIVATE pn_Extprice
SUM(quotes1.extprice) for quotes1.quote=thisform.txtquote.value to pn_Extprice

also on the report, for the field pn_Extprice, under the Calculations I checked the box next to sum.

The entire table only has two numbers I'm trying to add.
12 and 122.40, for some reason this is turning up as 24.
 
How about putting in a BROWSE right before the SUM to see which records are actually being summed.

BROWSE FOR quotes1.quote = thisform.txtquote.value

Jim
 
Try with PUBLIC instead.

"PRIVATE pn_Extprice"
 
Or...
You have no need to sum prior report.

Create variable in report and under "value to store" put:
iif(quotes1.quote = yourvalue,quotes1.quote,0)

and check sumary
 
If you need to sum a group of records in the middle of a large file, changing to FOR rather than WHILE will cause a performance problem.

How about saving the starting record number in a variable before you do the sum, and the GOTO the saved record after the sum?
 
Thanks for responding Jim. This works for me now if I select the work area just before I sum. I thought it was kind of strange though because if I only had one item on the report it pulled the correct item from the correct table for me. Oh well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top