muhammasif
asked on
Invalid Use of NULL
Hello,
A VB .exe application is launched. Then, a menu item is used to export a query to a text file. When the menu item is run, it exports some records and then stops indicating:
'Error (94) exporting file. Invalid use of Null.'
I have deleted those records off the tables where the application stops but nothing happened.
Thanks.
A VB .exe application is launched. Then, a menu item is used to export a query to a text file. When the menu item is run, it exports some records and then stops indicating:
'Error (94) exporting file. Invalid use of Null.'
I have deleted those records off the tables where the application stops but nothing happened.
Thanks.
Your problem statement is not entirely clear but it sounds as though you are trying to map one field to another where the source data is NULL and the target data does not allow null values in that column. Please elaborate...
OOPS, excuse me. I overlooked the fact that you are exporting to a text file... Still I think more info is required before anyone can be of much help.
Post your code. It sounds as if certain columns contain NULL data. Your export routine should account for this using something like:
If IsNull(rs.Fields("FieldNam e")) = True Then
'write a blank string or something
Else
'write the actual value of rs.Fields("FieldName")
End If
If IsNull(rs.Fields("FieldNam
'write a blank string or something
Else
'write the actual value of rs.Fields("FieldName")
End If
Everybody sees this error about a million times.
Instead of loads of if statements I use a function:
text1 = Git(RS("MyField"))
text2 = Format(GitNum(RS("MyAmount ")), "0.00")
Public Function Git(dt)
' Use this function when accessing ALL recordset fields
' To avoide ilegal use of Null error
If IsNull(dt) Then
Git = ""
Else
Git = dt
End If
End Function
Public Function GitNum(dt)
' Use this function when accessing ALL record set fields
' To avoide ilegal use of Null error
If IsNull(dt) Then
GitNum = 0
Else
GitNum = dt
End If
End Function
Instead of loads of if statements I use a function:
text1 = Git(RS("MyField"))
text2 = Format(GitNum(RS("MyAmount
Public Function Git(dt)
' Use this function when accessing ALL recordset fields
' To avoide ilegal use of Null error
If IsNull(dt) Then
Git = ""
Else
Git = dt
End If
End Function
Public Function GitNum(dt)
' Use this function when accessing ALL record set fields
' To avoide ilegal use of Null error
If IsNull(dt) Then
GitNum = 0
Else
GitNum = dt
End If
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
pierrecampe, where/how should I append ""?
Thanks.
Thanks.
result = mydata & ""
or
mydata = mydata & ""
For pierre...
or
mydata = mydata & ""
For pierre...