
Question: SQL Server 6.5, VB5
Michael,
Null values cannot be assigned to "typed" VB variables. You must use
variants or
Substitute a Null value by some default that indicates the value was null.
You could then
write a function ReplaceNull as follows --
Function ReplaceNull(ByVal varIN As Variant, ByVal constValue As Variant) As
Variant
On Error Resume Next
If Trim$(varIN & "") = "" Then
ReplaceNull = constValue
Else
ReplaceNull = Trim(varIN)
End If
End Function
Then in your code, if testudt.TestMoney is a Currency, Use --
testudt.TestMoney = CCur(ReplaceNull(rs!MoneyColumn, -999.99))
where -999.99 is a default that indicates a Null condition.
-Jay
Quote:
>I've played with this problem a little more and found out the problem is
>encountered when I have a <NULL> in the table column. I need the <NULL>
>value... it indicates this item is not used, or unknown.
>I've tried to assign the value of the column from the ADO recordset to a
>udt, but get "invalid use of null" errors. I've appended a "" (null
string),
>but get a type mismatch.
>What gives?
>How can I allow use of <NULL> in a table column, assign it to a variable
and
>allow the textbox to be loaded with the value from the UDT variable without
>raising all these errors.?
>Thanks
>Michael D Jackson