473,322 Members | 1,504 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,322 software developers and data experts.

Null Value


Hi,

I added a field to my company table (PBV_rstCompany.Fields("Installer")) the
default value of the field is Null. I place this If statement and it doesn't
work

If PBV_rstCompany.Fields("Installer") <> "Y" Then
txtInstaller.Visible = False
lblInstallerLBL.Visible = False
cmdNextInstaller.Visible = False
cmdPrevInstaller.Visible = False
End If

It assumes the statement is false when in fact it's true... Null in not
equal "Y"!

Aug 31 '05 #1
2 1940
>I added a field to my company table (PBV_rstCompany.Fields("Installer")) the
default value of the field is Null. I place this If statement and it doesn't
work

If PBV_rstCompany.Fields("Installer") <> "Y" Then
txtInstaller.Visible = False
lblInstallerLBL.Visible = False
cmdNextInstaller.Visible = False
cmdPrevInstaller.Visible = False
End If

It assumes the statement is false when in fact it's true... Null in not
equal "Y"!
Get used to SQL 3-valued logic. The result of:

PBV_rstCompany.Fields("Installer") <> "Y"
when the left side is null has the value null, not false or true.
Similarly,
x = null
is never true, it's null. The correct test is
x is null

You probably want to write your test:
If PBV_rstCompany.Fields("Installer") <> "Y"

or PBV_rstCompany.Fields("INstaller") is null
Then

Gordon L. Burditt
Aug 31 '05 #2
Joel wrote:
I added a field to my company table (PBV_rstCompany.Fields("Installer")) the
default value of the field is Null. I place this If statement and it doesn't
work


Almost any expression involving a NULL yields a NULL as the value of the
expression. A NULL expression in a boolean condition such as your IF
works like FALSE for purposes of satisfying the condition.

In SQL, NULL is a state, not a value. You cannot compare NULL to
anything -- it will always yield NULL. The idea is that NULL represents
the absence of a value, or an unknown value, or a value that has not
been set yet. E.g., is my middle name "Kevin"? We cannot say for
sure--no value has been entered in the middle_name field yet.

If you must have a non-null state in your "Installer" field, then you
should delare it as a NOT NULL field in your schema, and perhaps also
give it a DEFAULT value. This is appropriate if you have a field that
_must_ be either "Y" or "N", and using NULL to indicate an absence of a
value is meaningless for that field.

Otherwise you must handle the case of a NULL state differently than
handling value comparisons. SQL provides a predicate IS [NOT] NULL,
which returns true or false.

Regards,
Bill K.
Aug 31 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Morgan | last post by:
In an SQL statement which concatenates several fields I get a null value returned if any one of the fields are null. Is this to be expected? For example : SELECT tblMember.memberAddress + '...
3
by: iStrain | last post by:
Hiya. I'm _sure_ this is an FAQ, but Googling hasn't produced the answer in a way I can make sense out of. I know I should get this, but so far no way... I'm creating tables and doing queries in...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
102
by: junky_fellow | last post by:
Can 0x0 be a valid virtual address in the address space of an application ? If it is valid, then the location pointed by a NULL pointer is also valid and application should not receive "SIGSEGV"...
99
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
13
by: Federico Balbi | last post by:
Hi, I was wondering if PGSQL has a function similar to binary_checksum() of MS SQL Server 2000. It is pretty handy when it comes to compare rows of data instead of having to write long boolean...
64
by: yossi.kreinin | last post by:
Hi! There is a system where 0x0 is a valid address, but 0xffffffff isn't. How can null pointers be treated by a compiler (besides the typical "solution" of still using 0x0 for "null")? -...
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...
15
by: khan | last post by:
Hi, I read that pointer representation can non-zero bit pattern, machine specific.Compiler when comes accross value '0' in pointer context, converts it to machine specific null pointer...
3
ADezii
by: ADezii | last post by:
Null as it relates to database development is one of life's little mysteries and a topic of total confusion for novices who venture out into the database world. A Null Value is not zero (0), a zero...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.