I have a date field in my access database linked to a text box on my form. When the user deletes the date - how do I put a null field into my text bos so that when I update it is not invalid?
Printable View
I have a date field in my access database linked to a text box on my form. When the user deletes the date - how do I put a null field into my text bos so that when I update it is not invalid?
'Convert NULL Values to Empty Strings to Avoid Errors
'One way to avoid errors from occurring when retrieving NULL values from a recordset object is to inspect the field's value.
'If it is NULL, then convert it to an empty string or zero. For example:
If isnull(rs("Field")) then tmp="" else tmp=rs("Field") form.textfield=tmp
'An even simpler way is to use the format function, which will convert a NULL value to an empty string automatically, avoiding any error messages.
'It will look like this:
form.textfield=format(rs("Field"))
An even simpler way is to disallow the use of Nulls at the table level and then just validate the user input.
NULLS ARE EVIL!!!
Seriously, avoiding them will save a lot of hassle.
Cheers,
Paul.