Simply report with iif control
Hi,
I'm working with Fastreport 4, in order to make a simply report. This report was made from only one table on a Postgress DB. The problem is this: inside the table there is some colum that can haven't any value (enpty). For the colum "Currency",for example, the possible values are USD,YEN and enpty. When the value is enpty mean that the currency is EUR (Because I'm in Italy).
I will show in the report EUR when the value is enpty and for other currency it's ok bedause just are write in the colum's table.
I try to use a variable to obtain this,and inside the expression I wrote this:
IIF((<table."currency">is null),"EUR",<table."currency">)
if I put the varian field inside the report, the program give me a error:
Varialbe: Invalid argument
Variable: Varialbe: Invaluid argument
I have also another problem, inside the DB there is some colum date type and inside there isn't the value 0 but there is the value 01/01/1900. I want tho show in the report 0 when the colum's value is 01/01/1900.
i used another variable to check it and the expression that I wrote is:
IIF(((<Lista_Ordini_Fornitore."data_ppr">)> FormatDateTime(dd/mm/yyyy,01/01/1990)),"OK","NO")
Data1: Error in expression'IIF...........)':Undeclares identifier: 'dd'
someone can help me?
thank you very much
I'm working with Fastreport 4, in order to make a simply report. This report was made from only one table on a Postgress DB. The problem is this: inside the table there is some colum that can haven't any value (enpty). For the colum "Currency",for example, the possible values are USD,YEN and enpty. When the value is enpty mean that the currency is EUR (Because I'm in Italy).
I will show in the report EUR when the value is enpty and for other currency it's ok bedause just are write in the colum's table.
I try to use a variable to obtain this,and inside the expression I wrote this:
IIF((<table."currency">is null),"EUR",<table."currency">)
if I put the varian field inside the report, the program give me a error:
Varialbe: Invalid argument
Variable: Varialbe: Invaluid argument
I have also another problem, inside the DB there is some colum date type and inside there isn't the value 0 but there is the value 01/01/1900. I want tho show in the report 0 when the colum's value is 01/01/1900.
i used another variable to check it and the expression that I wrote is:
IIF(((<Lista_Ordini_Fornitore."data_ppr">)> FormatDateTime(dd/mm/yyyy,01/01/1990)),"OK","NO")
Data1: Error in expression'IIF...........)':Undeclares identifier: 'dd'
someone can help me?
thank you very much
Comments
I don't know why but sometimes the programm goes in error and all it's wrong.
Now work corectly.
thank you
default is convert nulls true this converts nulls to 0 if numeric or empty string if a null string.
to check for null you must set this property to false or check for 0 if numeric or empty string if string.
using the iif function substitutes one string for another depending upon boolean value of the expression.
and is used within a memoview or an expression.
typical example when engine option is default.
in the memo
[IIF(<Customers."Addr2">='',<Customers."City">,<Customers."Addr2">)]
note the [].
the next thing for you to understand is categorized variables these variables expect a valid expression,
a numeric or a delimited string.
or they trigger the ogv event of the tfrxreport component at the delphi level and if no event handler is found an error results.
therefore if you want put a sting value in the expression you need to add extra ' delimiters as the
script like delphi strips the delimiter.
your expression
IIF((<table."currency">is null),"EUR",<table."currency">)
needs to be enclosed in []
[IIF((<table."currency">is null),'EUR',<table."currency">)]
and the engine option convert nulls must be set to false
or your expression should be
[IIF(<table."currency"> = '','EUR',<table."currency">)]