473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

When Null field = Null field, the results are FALSE?

133 100+
When testing the following code, the results should be true, however, a false results is generated. I don't understand why and i need to maintain the data values.

Expand|Select|Wrap|Line Numbers
  1.      If strTEMP_CORD_No = rstTemp!CORD_No Then
  2.             strTEMP_BANNERPOAmt = strTEMP_BANNERPOAmt + rstTemp!BANNERPOAmt
  3.         Else
  4.             MsgBox "cord no not equal"
  5.         End If
  6.  
Mar 5 '12 #1
4 1264
Rabbit
12,516 Expert Mod 8TB
You have to use the IsNull or Nz functions if you want to compare nulls. Null fields can be anything, so they never match each other in a binary comparison. Which is what the = binary comparison operator does.
Mar 5 '12 #2
dowlingm815
133 100+
i modified the code using the IsNull in the following matter.

Expand|Select|Wrap|Line Numbers
  1.      If IsNull(strTEMP_CORD_No) Then
  2.             If IsNull(rstTemp!CORD_No) Then
  3.                     strTEMP_BANNERPOAmt = strTEMP_BANNERPOAmt + rstTemp!BANNERPOAmt
  4.             End If
  5.         Else
  6.             If strTEMP_CORD_No = rstTemp!CORD_No Then
  7.                 strTEMP_BANNERPOAmt = strTEMP_BANNERPOAmt + rstTemp!BANNERPOAmt
  8.             End If
  9.         End If
  10.  
Mar 5 '12 #3
Rabbit
12,516 Expert Mod 8TB
You could also use Nz
Expand|Select|Wrap|Line Numbers
  1. If Nz(Field1, "") = Nz(Field2, "") Then
  2.    ' Do something
  3. End If
Mar 5 '12 #4
NeoPa
32,556 Expert Mod 16PB
Is this a serious question?

You are asking why the result of comparing one entirely unspecified value with another equally unspecified value doesn't return a True result when you expect it to. Good luck with that.
Mar 5 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Keith | last post by:
I am Using Dreamweaver MX to create my site and have come accross a problem no one in the DW groups seems to be able to help with. When I submit an insert to my SQL database, any form value which...
4
by: Andy Hutchings | last post by:
Hi everybody - hope you can help out here. I have a form in a database, which is a columnar form from one of the tables in the db - there is a sub-form to the form which is a datasheet view of...
24
by: RHNewBie | last post by:
Hello, What is the difference between null and NULL. Are x == null and x == NULL the same? The compiler is gcc 3.2. Thanks.
6
by: FatboyCanteen | last post by:
When I using dataset to append a null value to the datetime field. It throw a error -> can not convert db.null to system.date Can there is any standard to pass a Null value to the DateTime...
12
by: Sadeq | last post by:
Is there a way to read a struct field by field? I want to write a rather general function, like: public string EncodeStruct (struct strct) { .... } which accepts a general struct type,...
17
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
2
by: ZEROFIVE | last post by:
Just wanted to know how would i go about making a Search field and search results page if someone wanted to search on my site? Thanks alot, Jimmy
1
by: kkshansid | last post by:
here txtFields(14).Text="NULL" For i = 0 To maxfield adoPrimaryRS.Fields(i).Value = txtFields(i).Text Next i at i=14 this loop gives error plz help...
2
by: Resmy Ravi | last post by:
how to make a field null in access
1
by: Ann Case | last post by:
I am very new to jscript especially as it pertains to delivering flash elements... That being said - here is what I am dealing with. Plugin for Wordpress embed-video-with-link. The site is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.