Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Null Values 1

Status
Not open for further replies.

campbere

Technical User
Oct 10, 2000
146
US
I am having problems getting null values to work in my VB 6 application. I am using Oracle 8 as well.

I have selected records into a resultset.

The first thing I want to do is break the resultset into two groups. The first group has a null value for the capacity column. The second group is not null (it contains a value).

I can't seem to get the statements to work using null. The first statement doesn't work at all but I was able to come up with a work around for the second group.

if RSData(&quot;capacity&quot;) <> &quot;&quot; Then
Open file
Print Records

Some other statements
endif

I tried the same technique for the first group null values but it didn't work.

if RSData(&quot;capacity&quot;) = &quot;&quot; Then
Open file
Print Records

Some other statements
endif

Has anyone else ever had this problem? Any suggestions, thoughts?
 
campbere,

&quot;&quot; is not Null. Null means that something doesn't have a value or is undefined. Since &quot;&quot; has a finite value, it IS defined. So if you compare Null to &quot;&quot; it will ALWAYS be false, because &quot;&quot; is not the same as Null.

Having said that, there are ways in Visual BASIC that let you work with Null Values. One of them is IsNull(). So if you wanted to see if your value was Null you would do this:
Code:
If IsNull(RSData!Capacity) Then
    Open file
    Print Records
End If
Sometimes you want to treat Null and and empty string &quot;&quot; the same. You can do this:
Code:
If Len(RSData!Capacity &amp; &quot;&quot;) = 0 then
    Open file
    Print Records
End If
Snaggs
tribesaddict@swbell.net
There are two kinds of people in life: people who like their jobs, and people who don't work here anymore.
 
As snaggs stated &quot;&quot; is a null STRING, meaning a string variable with no characters. Null is not the same as &quot;&quot; and &quot;&quot; is not the same as a space, ie &quot; &quot;. 3 different values, null, null string and space.

You can check for Null several ways:

If IsNull(flda) then
or
If IsNull(flda) = True then
or
If flda = Null then
 
Thanks for the help everyone.

I would have replied sooner but I was too busy dancing in the street. lol

I did have to make one small edit to your suggestion I has to write: if (isnull(RSData(&quot;capacity))) then

just needed one more set of parenthisis to get it to run.

Thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top