George Mauer
George Mauer

Reputation: 122072

Crystal Reports - "A string is required here" formula error

I have a command line utility that generates one simple crystal report. I recently updated the project from .NET 1.1 to .NET 3.5 using the Visual Studio 2008 migrator and am now getting an error that I had never received before.

The problem is in the work_order formula which is as follows:

stringVar nvl_ship_wrk_id := "0";
stringVar nvl_ship_wrk_seq := "0";

If Not IsNull({FeedBOLInput.ShipWrkId}) Then 
    nvl_ship_wrk_id := {FeedBOLInput.ShipWrkId}; 

If Not IsNull({FeedBOLInput.ShipWrkSeq}) Then 
    nvl_ship_wrk_seq := {FeedBOLInput.ShipWrkSeq};

nvl_ship_wrk_id & " - " & nvl_ship_wrk_seq;

And the error is:

- InnerException    {"A string is required here.
Error in File C:\\...\\temp_88c50533-02c6-4973-ae06-ed0ab1a603ac {0D5E96FB-038A-41C5-93A7-A9D199961377}.rpt:
Error in formula  <work_order>. 
'stringVar nvl_ship_wrk_id := \"0\";
'
A string is required here."}    System.Exception {System.Runtime.InteropServices.COMException}

Does anyone have any idea what this can be? I'm out of clues. The dataset is coming in properly - and the error seems to point to a row which merely initializes a variable.

Upvotes: 4

Views: 24595

Answers (1)

Dusty
Dusty

Reputation: 4697

You can try to cast the {FeedBOLInput.ShipWrkId} and {FeedBOLInput.ShipWrkSeq} to a string to make sure that it is coming across as a string.

I'm not sure why what you have wouldn't work, but see if the below works for you.

stringVar nvl_ship_wrk_id := "0";
stringVar nvl_ship_wrk_seq := "0";

If Not IsNull({FeedBOLInput.ShipWrkId}) Then 
    nvl_ship_wrk_id := CStr({FeedBOLInput.ShipWrkId}); 

If Not IsNull({FeedBOLInput.ShipWrkSeq}) Then 
    nvl_ship_wrk_seq := CStr({FeedBOLInput.ShipWrkSeq});

nvl_ship_wrk_id & " - " & nvl_ship_wrk_seq;

Upvotes: 7

Related Questions