Best method to update a value

I have a form that uses tbl1 and in that table I have 5 fields.

ID
Name
Date
Status
Notes

I need to be able to set the status field to 1 if there is a date entered in date. If the date is Null or blank I need it to be 0.

I can get it to work with an if statement like this:



IF({date} != Null)
  {
     ({status} = 1);
  }
else
  {
      ({status} = 0);
  }


When I enter a date in the date field and click update or save it will change the value to 1 in status. However, when I delete the date from the date field and click save it does not change the value of status to 0.

What am I missing?

You’d better check for empty


if ( empty({date}) )
{
  {status} = 0;
}
else
{
   {status} = 1;
}

If that’s not working, try this.
Looks strange but it’s not a typo: it’s a check for a a string with the value of ‘null’.


if ( empty({date}) OR {date} == 'null' )
{
  {status} = 0;
}
else
{
   {status} = 1;
}

i figured this out… the ‘Null’ had to be changed to ‘null’ I made sure the database set the empty field to null so it is working great now…

Thank you for the assistance