agzis
asked on
IsNull function error
When I call function IsNull against ADO recordset values I'll receive an error that function IsNull should support array datatype. Why this happened? Thanks.
Can you show the code snippit that is giving you this error as well as the data type of the column that it is blowing up on?
ASKER
Dim i, j As Integer
'i-col;j-row
j = 1: i = 0
If Not Reds.EOF Then Reds.MoveFirst
While Not Reds.EOF
If SSheet.Rows <= j Then
SSheet.Rows = SSheet.Rows + 1
End If
SSheet.Row = j
For i = 0 To (Reds.Fields.Count - 1)
SSheet.Col = i
If IsNull(Reds(i)) Then
SSheet.Text = ""
Else
SSheet.Text = Trim(Reds(i))
End If
Next i
Reds.MoveNext
j = j + 1
Wend
'i-col;j-row
j = 1: i = 0
If Not Reds.EOF Then Reds.MoveFirst
While Not Reds.EOF
If SSheet.Rows <= j Then
SSheet.Rows = SSheet.Rows + 1
End If
SSheet.Row = j
For i = 0 To (Reds.Fields.Count - 1)
SSheet.Col = i
If IsNull(Reds(i)) Then
SSheet.Text = ""
Else
SSheet.Text = Trim(Reds(i))
End If
Next i
Reds.MoveNext
j = j + 1
Wend
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Function NullText(Text As Variant) As String
If IsNull(Text) Then
NullText = vbNullString
Else
NullText = Text
End If
End Function
SSheet.Text = NullText(trim(Reds(i))
If IsNull(Text) Then
NullText = vbNullString
Else
NullText = Text
End If
End Function
SSheet.Text = NullText(trim(Reds(i))
Another option is not to use isnull, a faster way that I've found is as follows
variable = rscordset.fields("fieldnam e") & ""
This will never pop up the Invalid use of null error.
variable = rscordset.fields("fieldnam
This will never pop up the Invalid use of null error.