Terminate unterminated statements
Check if value is null before trying to use it.

When clearing the form, the value will be null and attempting to use it will generate an error.