Check for Null before inserting into Database

Here’s a function to ensure a Null value gets inserted into the database.

Function CheckForNULL(strStringToCheck) if len(trim(strStringToCheck)) = 0 then CheckForNULL =dbNull.Value else CheckForNULL = strStringToCheck end if end function

If you have a DateTime field, without a function like this, a default date will be entered (ie 1/1/1900 12:00:00 AM), instead of null, when your insert is executed.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>