473,498 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

form controls not really null??

I have a list box whose value I explicitly set to null in code.
Then when I include the list box in a query criteria it fails to match
but if I replace the criteria with 'null' then it matches fine.
So the code (cleaned up from that written by the query builder) looks
like this and works fine
SELECT TechnicalCategory FROM tblPrintParts WHERE Description Is Null;

but the following doesn't
SELECT TechnicalCategory FROM tblPrintParts WHERE Description
=[Forms]![Form2]![lstLevel3]

however in code i have a little debug statement
IF ISNULL(lstLevel3) then msgbox "list is null"

This is trigered
:( help please

Jan 4 '06 #1
3 1180
The behavior you describe is by design.
Two nulls are not equal.
If you think of Null as meaning Unknown, that will make sense.
More detail in:
Common errors with Null
at:
http://allenbrowne.com/casu-12.html

You can fix the query to print all records when the list box is null like
this:
SELECT TechnicalCategory FROM tblPrintParts
WHERE ([Description] = [Forms]![Form2]![lstLevel3])
OR ([Forms]![Form2]![lstLevel3] Is Null);

If you wanted to only select the records where Description is null when the
list box value is null:
SELECT TechnicalCategory FROM tblPrintParts
WHERE ([Description] = [Forms]![Form2]![lstLevel3])
OR ([Forms]![Form2]![lstLevel3] Is Null AND [Description] Is Null);

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<or******@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a list box whose value I explicitly set to null in code.
Then when I include the list box in a query criteria it fails to match
but if I replace the criteria with 'null' then it matches fine.
So the code (cleaned up from that written by the query builder) looks
like this and works fine
SELECT TechnicalCategory FROM tblPrintParts WHERE Description Is Null;

but the following doesn't
SELECT TechnicalCategory FROM tblPrintParts WHERE Description
=[Forms]![Form2]![lstLevel3]

however in code i have a little debug statement
IF ISNULL(lstLevel3) then msgbox "list is null"

This is trigered
:( help please

Jan 4 '06 #2
<or******@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a list box whose value I explicitly set to null in code.
Then when I include the list box in a query criteria it fails to match
but if I replace the criteria with 'null' then it matches fine.
So the code (cleaned up from that written by the query builder) looks
like this and works fine
SELECT TechnicalCategory FROM tblPrintParts WHERE Description Is Null;

but the following doesn't
SELECT TechnicalCategory FROM tblPrintParts WHERE Description
=[Forms]![Form2]![lstLevel3]

however in code i have a little debug statement
IF ISNULL(lstLevel3) then msgbox "list is null"

This is trigered
:( help please

In the first you have Is Null and in the second you are using "=". You
cannot find records where the description "equals null". You either have to
treat null values differently from any type of string, or use the Nz
function which turns nulls into zero-length strings (by default).
Jan 4 '06 #3
fixed with what I felt is simplest way using Nz function on both the
value from the table and the value from the form - thanks

Jan 4 '06 #4

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

Similar topics

10
4922
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading....
6
6205
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
11
3457
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
4393
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
2413
by: ahmad.humyn | last post by:
I want to call a hidden form. My code goes something like in which the main calls form1. form1 has a button which creates & calls form2 and hides itself. Now I have a button in form2 which if...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7165
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
7203
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
5462
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,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.