Solved

Invalid Use of NULL

Posted on 2002-05-23
7
304 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:muhammasif
7 Comments
 
LVL 4

Expert Comment

by:trkcorp
ID: 7030571
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
 
LVL 4

Expert Comment

by:trkcorp
ID: 7030574
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 7030612
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 17

Expert Comment

by:inthedark
ID: 7030699
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
 
LVL 6

Accepted Solution

by:
pierrecampe earned 100 total points
ID: 7030724
to each field you 'export' append "" (zero lenght string)
that way there are never NULL's
0
 

Author Comment

by:muhammasif
ID: 7042459
pierrecampe, where/how should I append ""?

Thanks.
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 7042980
result = mydata & ""
or
mydata = mydata & ""

For pierre...
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question