FR4 IIF Error "Identifier expected"
Hi All,
I try to use IIF on a Memo Field to display a field value or a string.
The Expression I use is:
[IIF([frxAuftrag."BESTELLPREIS"] = -1,,[frxAuftrag."BESTELLPREIS"])]
It should print the string '-/-' it the field value is -1.
When I try to run the report, it stops with the error "Identifier expected".
I already tried using <> and [] as delimiters. Exchanged true and false values. No change.
Is there some help about using the expressions on Fields?
Or is there an example report where I can find it?
Or does anyone advise me how to do it right?
TIA Rolf
I try to use IIF on a Memo Field to display a field value or a string.
The Expression I use is:
[IIF([frxAuftrag."BESTELLPREIS"] = -1,,[frxAuftrag."BESTELLPREIS"])]
It should print the string '-/-' it the field value is -1.
When I try to run the report, it stops with the error "Identifier expected".
I already tried using <> and [] as delimiters. Exchanged true and false values. No change.
Is there some help about using the expressions on Fields?
Or is there an example report where I can find it?
Or does anyone advise me how to do it right?
TIA Rolf
Comments
should be
[IIF(<frxAuftrag."BESTELLPREIS"> = -1),'-/-',<frxAuftrag."BESTELLPREIS">]
Thank you.
Tried, but now the exception is: ';' expected.
inside the expression and at the end doesn't help.
Any idea?
TIA Rolf
Nowadays, when that happens I write the equivalent expression in the script. This is IMO also more readable, but it means that one must at least have the Standard edition of FR.
How would I do this in a script?
I have the appropriate version, but never installed Scripting.
Could you please outline (short) how to do an IIF in script?
(not the symtax but more how to get the script into the report)
TIA
Rolf
I tried this:
selected the Memofield in Question,
went to the "code" page of the reportdesigner,
entered the following code:
begin
if <frxAuftrag."BESTELLPREIS"> = -1 then
'-/- '
else <frxAuftrag."BESTELLPREIS">;
end.
run the report,
get the errormessage : "Script Error at 3:3:';' expected.
Changed the code to :
begin
if <frxAuftrag."BESTELLPREIS"> = -1 then
;'-/-'
else <frxAuftrag."BESTELLPREIS">;
end.
run the report,
get the same errormessage : "Script Error at 3:3:';' expected.
changed code to:
begin
if <frxAuftrag."BESTELLPREIS"> <> -1 then
<frxAuftrag."BESTELLPREIS">;
end.
run the report,
get the same errormessage : "Script Error at 3:1:';' expected.
I don't quite understand the logic in this.
I changed the code according to the error message some times more according to the error messages.
The report engine (?) expects a ';' before the "true" expression, even if there are already 1 or more.
So it looks like it can not read the code correct.
Any ideas?
TIA Rolf
if <frxAuftrag."BESTELLPREIS"> = -1 then
'-/- ' \\ i expect this string is what is causing the problem in any code written
else <frxAuftrag."BESTELLPREIS">;
end.
run the report,
get the errormessage : "Script Error at 3:3:';' expected
since i see a period after end it appears you have written this code in the empty begin end block of the code page instead of associating the code to and event of a band or memoview.
begin
if <frxAuftrag."BESTELLPREIS"> = -1 then
begin
memoname.allowexpressions := false;
memoname.memo.text= '-/- ';
end
else
begin
memoname.allowexpressions := true;
memoname.memo.text :=[frxAuftrag."BESTELLPREIS"]
end;
if you are going to use the script do it in the obp event of the band rather then in the obp of the memo.
then you can set the memoview's memo.text property.
Works perfect
(a last "end;" is missing)
Thank you very much.
Rolf
the solution from the FR Support:
[IIF(<frxAuftrag."BESTELLPREIS"> = -1,'-/-',<frxAuftrag."BESTELLPREIS">)]
works fine.
Rolf