Results 1 to 4 of 4

Thread: [RESOLVED] Whats wrong with this code?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Resolved [RESOLVED] Whats wrong with this code?

    I feel like this code should work! I want this formula to check for the appropriate dates and return the amount associated with it. What am I doing wrong????
    This code is in Crystal syntax
    //FUture START WITH NO END DATES
    If IsNull({ACH.Ending}) And {ACH.Starting} > CurrentDate Then
    "$" + {ACH.Amount}
    Else If IsNull({ACH.Ending1}) And {ACH.Starting1} > CurrentDate Then
    "$" + {ACH.Amount1}
    Else If IsNull({ACH.Ending2}) And {ACH.Starting2} > CurrentDate Then
    "$" + {ACH.Amount2}
    Else If IsNull({ACH.Ending3}) And {ACH.Starting3} > CurrentDate Then
    "$" + {ACH.Amount3}
    Else If IsNull({ACH.Ending4}) And {ACH.Starting4} > CurrentDate Then
    "$" + {ACH.Amount4}

    //CuRRENT START WITH NO END DATES
    Else If IsNull({ACH.Ending}) And {ACH.Starting} < CurrentDate Then
    "$" + {ACH.Amount}
    Else If IsNull({ACH.Ending1}) And {ACH.Starting1} < CurrentDate Then
    "$" + {ACH.Amount1}
    Else If IsNull({ACH.Ending2}) And {ACH.Starting2} < CurrentDate Then
    "$" + {ACH.Amount2}
    Else If IsNull({ACH.Ending3}) And {ACH.Starting3} < CurrentDate Then
    "$" + {ACH.Amount3}
    Else If IsNull({ACH.Ending4}) And {ACH.Starting4} < CurrentDate Then
    "$" + {ACH.Amount4}

    //NORMAL DATES
    Else If {ACH.Starting} < CurrentDate And {ACH.Ending} > CurrentDate Then
    "$" + {ACH.Amount}
    Else If {ACH.Starting1} < CurrentDate And {ACH.Ending1} > CurrentDate Then
    "$" + {ACH.Amount1}
    Else If {ACH.Starting2} < CurrentDate And {ACH.Ending2} > CurrentDate Then
    "$" + {ACH.Amount2}
    Else If {ACH.Starting3} < CurrentDate And {ACH.Ending3} > CurrentDate Then
    "$" + {ACH.Amount3}
    Else If {ACH.Starting4} < CurrentDate And {ACH.Ending4} > CurrentDate Then
    "$" + {ACH.Amount4}

    //FUTURE DATES
    Else If {ACH.Starting} > CurrentDate And {ACH.Ending} > CurrentDate Then
    "$" + {ACH.Amount}
    Else If {ACH.Starting1} > CurrentDate And {ACH.Ending1} > CurrentDate Then
    "$" + {ACH.Amount1}
    Else If {ACH.Starting2} > CurrentDate And {ACH.Ending2} > CurrentDate Then
    "$" + {ACH.Amount2}
    Else If {ACH.Starting3} > CurrentDate And {ACH.Ending3} > CurrentDate Then
    "$" + {ACH.Amount3}
    Else If {ACH.Starting4} > CurrentDate And {ACH.Ending4} > CurrentDate Then
    "$" + {ACH.Amount4}

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Whats wrong with this code?

    What am I doing wrong????
    What is the problem? Are you getting a coding error or processing error (ie wrong amount is returned)?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Re: Whats wrong with this code?

    Well, what happens is depending on what chunk of code is at the top, different values show up. Does the order of the code make the difference? e.g. If the "NORMAL DATES" code is at the top, then only those amounts show up, and it seems to ignore the "FUTURE START WITH NO END DATES" code chunk altogether. But the opposite happens when they are switched around. does this make sense to you?
    -cally

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Whats wrong with this code?

    I don't know your data or business process so can only make assumptions...

    does this make sense to you?
    Yes, it does. Assume

    Starting, Ending, Amount - Normal Date
    Starting1, Ending1, Amount1 - Normal Date
    Starting2, Ending2, Amount2 - Future Start No End Dates.

    Based on the code you posted Amount2 will be returned when the 3rd If statement is processed.
    Now move the Normal Dates section to the top. Amount will be returned when the 1st If statement in that section is processed.

Posting Permissions

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



Click Here to Expand Forum to Full Width