Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2006
    Posts
    14

    Unanswered: 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

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

  3. #3
    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?

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    PRINT WHEN empty(sum(jan)) ?
    George
    Home | Blog

  5. #5
    Join Date
    Jun 2006
    Posts
    14
    The problem is: he does not understand SUM in PRINT WHEN!!!

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •