If rstTable.Fields(2) = Null Then
strDescription = " "
Else
strDescription = rstTable.Fields(2)
'"Invalid use of null" error occurs right here. How can this be?
End If
Printable View
If rstTable.Fields(2) = Null Then
strDescription = " "
Else
strDescription = rstTable.Fields(2)
'"Invalid use of null" error occurs right here. How can this be?
End If
Try replacing Null with vbNullString.
replace
If rstTable.Fields(2) = Null Then
with
if isnull(rstTable.Fields(2) then
and
strDescription = rstTable.Fields(2)
with
strDescription = rstTable.Fields(2) & ""
I had a problem like this also. If you are dealing with SQL
the definition for Null does not work with VB's Definition.
If none of the previous suggestions work declare a Variable
of Type Varient. Put the database value in the variable and
then do your IF statement. That should do it.
You can use:
If blahblah = Null
VB Code:
Use If IsNull(blahblah) = true then 'you got your null else 'value is correct end if
I meant:
"You can't use:"
In ASP (VBScript), that won't work. Believe me, I've hit this wall before.
Try This:VB Code:
If Len(rstTable.Fields(2).Value & "") = 0 Then strDescription = "" Else strDescription = rstTable.Fields(2).Value End If
Just:No care about if it's null or not.VB Code:
strDescription = "" & rstTable.Fields(2)