Link to home
Start Free TrialLog in
Avatar of muhammasif
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.
Avatar of trkcorp
trkcorp

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("FieldName")) = True Then
    'write a blank string or something
Else
    'write the actual value of rs.Fields("FieldName")
End If
Avatar of inthedark
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
ASKER CERTIFIED SOLUTION
Avatar of pierrecampe
pierrecampe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of muhammasif

ASKER

pierrecampe, where/how should I append ""?

Thanks.
result = mydata & ""
or
mydata = mydata & ""

For pierre...