473,385 Members | 2,069 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,385 software developers and data experts.

Problem detecting Null

I am using Acess 2000 and Windows 2000.

I have a form with a text box txLName. tStrGlobal As String is dimensioned
globally. The first time I enter the text box, the Enter event with the code

If txLName.Value = Null Then
tStrGlobal = ""
Else
tStrGlobal = txLName.Value ' error occurs in this line
End If

causes an "Invalid use of null" error in the assignment statement after the
Else statement. Why doesn't the If statement correctly detect the Null?

The following code works fine

If txLName.Value <> Null Then
tStrGlobal = txLName.Value
Else
tStrGlobal = ""
End If

I'm not stuck, so please reply at your convenience. I'm just trying to
better understand how Access works. I'm a relative newbie.

Paul Core
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Apr 13 '06 #1
5 1721
On Thu, 13 Apr 2006 16:26:54 GMT, co******@aol.com wrote:
I am using Acess 2000 and Windows 2000.

I have a form with a text box txLName. tStrGlobal As String is dimensioned
globally. The first time I enter the text box, the Enter event with the code

If txLName.Value = Null Then
tStrGlobal = ""
Else
tStrGlobal = txLName.Value ' error occurs in this line
End If

causes an "Invalid use of null" error in the assignment statement after the
Else statement. Why doesn't the If statement correctly detect the Null?

The following code works fine

If txLName.Value <> Null Then
tStrGlobal = txLName.Value
Else
tStrGlobal = ""
End If

I'm not stuck, so please reply at your convenience. I'm just trying to
better understand how Access works. I'm a relative newbie.

Paul Core

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


Use:

If IsNull(txLName) Then

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Apr 13 '06 #2

On 13-Apr-2006, fredg <fg******@example.invalid> wrote:
I am using Acess 2000 and Windows 2000.

I have a form with a text box txLName. tStrGlobal As String is
dimensioned
globally. The first time I enter the text box, the Enter event with the
code

If txLName.Value = Null Then
tStrGlobal = ""
Else
tStrGlobal = txLName.Value ' error occurs in this line
End If

causes an "Invalid use of null" error in the assignment statement after
the Else statement. Why doesn't the If statement correctly detect the
Null?

Use:

If IsNull(txLName) Then


Thanks, this works as intended.

Paul
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Apr 13 '06 #3
co******@aol.com wrote in
news:11************@sp6iad.superfeed.net:
I have a form with a text box txLName. tStrGlobal As String is
dimensioned globally. The first time I enter the text box, the
Enter event with the code

If txLName.Value = Null Then

Nulls are strange beasts.
See http://allenbrowne.com/casu-02.html

Part of the null issue is that (x = null) will evaluate FALSE if x
contains any value and null if x is null. It will never evaluate to
true.

always test using isnull(x) in VBA or where x is null IN sql ,
--
Bob Quintal

PA is y I've altered my email address.
Apr 13 '06 #4
Null propagates so (x = Null) returns Null, no matter the value of x

e.g.
Dim x
x = Null
Debug.Print IsNull(x = Null)
x = 1
Debug.Print IsNull(x = Null)

Result
True
True

--

Terry Kreft
"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
co******@aol.com wrote in
news:11************@sp6iad.superfeed.net:
I have a form with a text box txLName. tStrGlobal As String is
dimensioned globally. The first time I enter the text box, the
Enter event with the code

If txLName.Value = Null Then

Nulls are strange beasts.
See http://allenbrowne.com/casu-02.html

Part of the null issue is that (x = null) will evaluate FALSE if x
contains any value and null if x is null. It will never evaluate to
true.

always test using isnull(x) in VBA or where x is null IN sql ,
--
Bob Quintal

PA is y I've altered my email address.

Apr 14 '06 #5
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:9L********************@karoo.co.uk:
Null propagates so (x = Null) returns Null, no matter the
value of x

That's what I think i meant to say..
e.g.
Dim x
x = Null
Debug.Print IsNull(x = Null)
x = 1
Debug.Print IsNull(x = Null)

Result
True
True


--
Bob Quintal

PA is y I've altered my email address.
Apr 14 '06 #6

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

Similar topics

4
by: bissatch | last post by:
Hi, Is it possible to write a script that, when provided with a database, it will return all the tables names? I will go onto try and put together a script that will not only output the table...
19
by: Gav | last post by:
Hi, At the moment i am checking that all the fields have been filled out, at the moment i am using the following... if firstname = "" and surname = "" and address1 = "" and town = "" and county...
1
by: dschmidt | last post by:
Does anybody know how to detect a NULL in a geometric box type? When I execute the following sql statement (coords is a box type) autotest=# select coords from dlg_control limit 1 autotest-# \g...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
9
by: D. Shane Fowlkes | last post by:
I'm using SQL Server 2000 and on my page, I'm simply creating a SQLDataReader and filling in Labels with the retrieved (single) record. However, how can I prevent from getting errors when a field...
0
by: nleesy | last post by:
Our web application running on WebSphere hits the following two exceptions randomly (once or twice a day) while opening connection to db2. Does anyone has idea about the cause of the exception. We...
1
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to...
5
by: Ravi | last post by:
in my script i declared one variable as global.I am tying to acess it in a function but it is not comming in Mozilla . it is executing in ie. My code is var http = createRequestObject();...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.