Lazarus

Programming => Packages and Libraries => LazReport => Topic started by: runs on March 26, 2023, 01:18:04 pm

Title: Check if field is Null [SOLVED]
Post by: runs on March 26, 2023, 01:18:04 pm
How could a check whether a field is null in the script section?

I tried  [field]= nil but arises an error that nil does not exits. Also try [field].IsNull but an error too.

Thanks.
Title: Re: Check if field is Null
Post by: Thaddy on March 26, 2023, 01:24:52 pm
Need more info, preferably code that fails where you expect it to work.
Title: Re: Check if field is Null
Post by: runs on March 26, 2023, 07:20:32 pm
Need more info, preferably code that fails where you expect it to work.

for example,

Quote
if [DataMod.DsoPrint."Substitute_ID"] = nil then
    MmoSubstituted.Visible:=True;

I get an "undefined symbol" error
Title: Re: Check if field is Null
Post by: Thaddy on March 26, 2023, 07:45:11 pm
That is not a serious reply.
Title: Re: Check if field is Null
Post by: korba812 on March 26, 2023, 08:20:25 pm
Unfortunately, LazReport converts a database field value from null to an empty string or zero (depending on the field type). Try using the OnGetValue event.
Title: Re: Check if field is Null
Post by: runs on April 04, 2023, 11:30:13 am
Unfortunately, LazReport converts a database field value from null to an empty string or zero (depending on the field type). Try using the OnGetValue event.

Yes, it converts it to an integer, 0 for null. So it is mandatory to check for >0 to not null.

Thanks!
TinyPortal © 2005-2018