## 9 replies

Last post Aug 30, 2012 08:21 AM by sandston

• sandston

None

0 Points

5 Posts

### A String Required

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.

• Dan Bracuk

Participant

1882 Points

1051 Posts

### Re: A String Required

Aug 30, 2012 05:58 AM|Dan Bracuk|LINK

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

• Rajesh Sawan...

Participant

1130 Points

239 Posts

### Re: A String Required

Aug 30, 2012 06:03 AM|Rajesh Sawant|LINK

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.

//Happy Coding

Regards,
RajeshS.
• sandston

None

0 Points

5 Posts

### Re: A String Required

Hey Dan,

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

• sandston

None

0 Points

5 Posts

### Re: A String Required

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)

• Ajay2707

Contributor

6622 Points

1743 Posts

### Re: A String Required

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})`

• sandston

None

0 Points

5 Posts

### Re: A String Required

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.

• Ajay2707

Contributor

6622 Points

1743 Posts

### Re: A String Required

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

• Ajay2707

Contributor

6622 Points

1743 Posts

### Re: A String Required

Hi,

see this also.

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

• sandston

None

0 Points

5 Posts

### Re: A String Required

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})