How can I read a NULL field from ACCESS into
a control in VB without getting Run Time
Error 94 (Invalid use of Null).
Example: Text1 = !Field1
When Field1 is 'empty' I get Run Time Error 94.
Printable View
How can I read a NULL field from ACCESS into
a control in VB without getting Run Time
Error 94 (Invalid use of Null).
Example: Text1 = !Field1
When Field1 is 'empty' I get Run Time Error 94.
If not isNull(!Field1) Then
Text1 = !Field1
End if
Worked PERFECT. Thanks damonous!
text1 = "" & !Field1
I don't trust the IsNull function, have had problems with it before.
VBs handling of null values is absolutely rubbish. Null can in fact be a perfectly accepted value.
e.g.
An inventory product; if quantity = null it generally means the product has never been held in stock, whereas quantity = 0 means that it is held in stock but currently there are none on hand.
This really bugs me....specially when you have to convert from other databases that can handle it ok.
Thats my moan for today.
I agree with Jethro.
I've written a function to check Null values as shown..
Private Function CheckNull(ByVal AValue as Variant) As Variant
if IsNull(AValue) Then
CheckNull = AValue
Else
CheckNull = ""
Endif
End Function
When I run my program it gives me some error message regarding NULL values... But the strange thing if i debug(F8) the program step by step NO ERRORS..
Hello All,
I use this little trick:
It works like a charm.Code:Text1 = !Field1 & ""
Best,
Very smart trick Rogers!!!
'speaking of tricks..here's another rs = recordset
Text1 = Format(rs("yourfieldname"))