Recent

Author Topic: Check if field is Null [SOLVED]  (Read 1821 times)

runs

  • New Member
  • *
  • Posts: 26
Check if field is Null [SOLVED]
« 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.
« Last Edit: April 04, 2023, 11:30:55 am by runs »
Projects: LibreStaff

Thaddy

  • Hero Member
  • *****
  • Posts: 14198
  • Probably until I exterminate Putin.
Re: Check if field is Null
« Reply #1 on: March 26, 2023, 01:24:52 pm »
Need more info, preferably code that fails where you expect it to work.
Specialize a type, not a var.

runs

  • New Member
  • *
  • Posts: 26
Re: Check if field is Null
« Reply #2 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
Projects: LibreStaff

Thaddy

  • Hero Member
  • *****
  • Posts: 14198
  • Probably until I exterminate Putin.
Re: Check if field is Null
« Reply #3 on: March 26, 2023, 07:45:11 pm »
That is not a serious reply.
Specialize a type, not a var.

korba812

  • Sr. Member
  • ****
  • Posts: 391
Re: Check if field is Null
« Reply #4 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.

runs

  • New Member
  • *
  • Posts: 26
Re: Check if field is Null
« Reply #5 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!
Projects: LibreStaff

 

TinyPortal © 2005-2018