Solved

Invalid Use of NULL

Posted on 2002-05-23
7
294 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to delete range 4 54
Determine Range to Select 5 33
Microsoft Access combo box help 2 28
vb6 connector to mongodb 2 26
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now