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.
muhammasifAsked:
Who is Participating?
 
pierrecampeConnect With a Mentor Commented:
to each field you 'export' append "" (zero lenght string)
that way there are never NULL's
0
 
trkcorpCommented:
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...
0
 
trkcorpCommented:
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.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
AzraSoundCommented:
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("FieldName")) = True Then
    'write a blank string or something
Else
    'write the actual value of rs.Fields("FieldName")
End If
0
 
inthedarkCommented:
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
0
 
muhammasifAuthor Commented:
pierrecampe, where/how should I append ""?

Thanks.
0
 
trkcorpCommented:
result = mydata & ""
or
mydata = mydata & ""

For pierre...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.