How to Avoid Nulls

  • Thread starter Thread starter Chaplain Doug
  • Start date Start date
C

Chaplain Doug

I have a table with a field COMMENTS of type "Memo." It
seems that when a new record is added the COMMENTS field
is Null. When I try to pass the contents of the field to
one of my functions it is kicked out as an error (Invalid
Use of Null). How may I ensure that when a record is
added that the COMMENTS field is empty but NOT NULL?
Thanks for any help. God bless.

Chaplain Doug
 
I have a table with a field COMMENTS of type "Memo." It
seems that when a new record is added the COMMENTS field
is Null. When I try to pass the contents of the field to
one of my functions it is kicked out as an error (Invalid
Use of Null). How may I ensure that when a record is
added that the COMMENTS field is empty but NOT NULL?

Try passing the reference to your field in the function's argument wrapped in
the Nz() function to pass an empty string ("") when the field is empty:

MyfunctionName(Nz(MemoFieldName, ""))

.... or simply append a null string to the reference:

MyfunctionName(MemoFieldName & "")
 
Hmmm......my test indicated that the value no longer was Null in this
situation.

Well, then Bruce's suggestion may be the better course.
 
I recommend you leave it at null, & fix the error(s) that are causing the
null value to be rejected.

For example, if you pass the memo field to this procedure:

Sub MyProc (pMemo as string)
...

fix it by (1) passing nz(TheMemoField,"") (instead of just TheMemoField),
or change the parameter declaration to As Variant.

HTH,
TC
 
Back
Top