locked
A String Required RRS feed

  • Question

  • User-1546231356 posted

    I am quite a newbie to Crystal Reports so bear with me if I do not provide all the relevant information first off. 

    Below is my formula: 

    if {?ARR_DEP} = "A" then 
    {FLIGHTD_ALL.ACTUAL} 
    else 
    if {FLIGHTD_ALL.CANCEL_CODE} = "C" then 
    "" 
    else 
    {FLIGHTD_ALL.OFFCHOCKS} 

    when I attempt to validate the formula advises me that a sring is required. 

    Any advice or guidance would be much appreciated. 

    Thursday, August 30, 2012 5:56 AM

Answers

  • User-1546231356 posted

    I have managed to find a solution for the problem thanks to everyone that assisted with this:

    if {?ARR_DEP} = "D" and {FLIGHTD_ALL.CANCEL_CODE} <> "C" then 

    "" 

    else 

    if {?ARR_DEP} = "A" and {FLIGHTD_ALL.CANCEL_CODE} <> "" then 

    ToText({FLIGHTD_ALL.ACTUAL})

    else 

    ToText({FLIGHTD_ALL.OFFCHOCKS}) 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 30, 2012 8:21 AM

All replies

  • User-1407477457 posted

    You have nested if/else blocks but the outer one is incomplete.

    Thursday, August 30, 2012 5:58 AM
  • User-1760637409 posted

    Hi,

    Kindly check the DataType for all mentioned below ,
    it may be possibility that data might be string & you are referring it as integer,

    ARR_DEP
    FLIGHTD_ALL.CANCEL_CODE
    FLIGHTD_ALL.OFFCHOCKS

    While comparing please check whether is it String or Numeric / Integers

    Hope this will work for you.

    Thursday, August 30, 2012 6:03 AM
  • User-1546231356 posted

    Hey Dan, 

    Thank you for the response, I understand vaguely is there an easy way around resolving the last incomplete nested if/else statement.

    Thursday, August 30, 2012 6:03 AM
  • User-1546231356 posted

    Hi Rajesh, 

    ARR_DEP is either an A or a D, 

    CANCEL_CODE is either blank or a C

    FLIGHTD_ALL.OFFCHOCKS is 23/07/2012  16:10:00 (for example)

    Thursday, August 30, 2012 6:16 AM
  • User-578610739 posted

    Hi Sandston,

    The output of this formula must be same either from if or else condition.

    FLIGHTD_ALL.OFFCHOCKS is 23/07/2012  16:10:00 (for example)

    In your datetime field, convert into string.

    ToText({your_date_field})

    Also please specify return keyword.

    Thursday, August 30, 2012 6:49 AM
  • User-1546231356 posted

    Hi Ajay, 

    I modified the code to:

    if {?ARR_DEP} = "A" then 
    {FLIGHTD_ALL.ACTUAL} 
    else 
    if {FLIGHTD_ALL.CANCEL_CODE} = "C" then 
    "" 
    else 
    ToText({FLIGHTD_ALL.OFFCHOCKS} )


    but advises a date-time is required here.

    Thursday, August 30, 2012 7:21 AM
  • User-578610739 posted

    Hi Sandston,

    check this.

    http://forums.asp.net/t/1221808.aspx/1

    http://stackoverflow.com/questions/1154785/crystal-reports-a-string-is-required-here-formula-error

    Thursday, August 30, 2012 7:27 AM
  • User-578610739 posted

    Hi,

    see this also.

    http://www.forumtopics.com/busobj/viewtopic.php?p=738951

    Thursday, August 30, 2012 7:28 AM
  • User-1546231356 posted

    I have managed to find a solution for the problem thanks to everyone that assisted with this:

    if {?ARR_DEP} = "D" and {FLIGHTD_ALL.CANCEL_CODE} <> "C" then 

    "" 

    else 

    if {?ARR_DEP} = "A" and {FLIGHTD_ALL.CANCEL_CODE} <> "" then 

    ToText({FLIGHTD_ALL.ACTUAL})

    else 

    ToText({FLIGHTD_ALL.OFFCHOCKS}) 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 30, 2012 8:21 AM