Solved

Invalid Use of NULL

Posted on 2002-05-23
7
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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