If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Other PC Databases > sum in foxpro report

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-10-07, 04:22
sge sge is offline
Registered User
 
Join Date: Jun 2006
Posts: 14
sum in foxpro report

Hello,
i want to make a normal report

1. jan feb mar
2. jan feb mar
-------------
SUM of jan feb mar

The last line is - normally - no problem with foxpro (Properties, calculation type SUM).
But now I need to colour it red, when the sum is <0
I tried to do it with the property "PRINT WHEN jan<0"
But then he checks the last value of jan (in the above example: 2. line)
When I try "PRINT WHEN sum(jan)<0" the error message appears "canīt find sum.prg".

How can I do it???
Thanks for any help!!!

sge
Reply With Quote
  #2 (permalink)  
Old 05-10-07, 04:54
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Can you use procedures?
Code:
Local MyVariable

MyVariable = sum(jan)
Do Case
Case MyVariable = 0
....
Otherwise
...
End Case
It's hard to find a solution here without knowing more about the problem.
Is sum(jan) a calculated field?
If so, what is the name of the field it is calculating the sum of?

I doubt the above will work, but give it a try
(it's been a while since I did reports in VFP!)
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 05-10-07, 05:32
sge sge is offline
Registered User
 
Join Date: Jun 2006
Posts: 14
Its a table with following structure

text jan feb mar
xx 30 31 32
yy 20 21 22
zz -10 11 12

and just a normal foxpro report:source is the above table with all fields
and a footer row with the sum of each column. The designer looks like this:

Detail
<text><jan><feb><mar>
Footer
"SUMME"<jan><feb><mar> <- each with the properity calculation type SUM

And the report looks like this:
xx 30 31 -32
yy 20 21 -22
zz -10 11 12
---------------------
SUMME 40 63 -42


Now I want to have black colour when sum is >0 (40 and 63) and red when sum <0 (-42).
I added the property PRINT WHEN jan(/feb/mar)>0 to each sum field and added three new sum fields with colour RED, properity calculation type SUM and property PRINT WHEN jan(/feb/mar)<0. So the footer looks like

"SUMME" <jan> calculation type SUM,colour black,PRINT WHEN jan>0
<jan> calculation type SUM,colour red,PRINT WHEN jan<0

Result is: 40 red , 63 black(ok), -42 black
because the PRINT WHEN looks at the last row of the detail part:
-10 is <0 => 40 is red
12 is >0 => -42 is black

When I say PRINT WHEN sum(jan)>0 => error: sum.prg not found

Is there any simple solution or have I to write my own sum.prg?
Reply With Quote
  #4 (permalink)  
Old 05-10-07, 06:39
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
PRINT WHEN empty(sum(jan)) ?
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 05-10-07, 07:06
sge sge is offline
Registered User
 
Join Date: Jun 2006
Posts: 14
The problem is: he does not understand SUM in PRINT WHEN!!!
Reply With Quote
  #6 (permalink)  
Old 05-10-07, 08:15
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Who's "he" ?

And no need to ge irate mate, I'm just throwing stuff into the pool and seeing if it floats.

Can you reference the textbox through code? Eg
Code:
If Textbox0.value = 0
Textbox0.forecolor = ...
EndIf
Or something similar? Let's step away from PRINT WHEN for a moment and think of a new approach.
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On