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

Validation If Null and Empty String

Are the following two validation the same:
1) IsNull(Me.ColumnName) and Me.ColumnName = ""
2) Me.ColumnName """

It would seem to be better to use: Me.ColumnName """

Feb 23 '07 #1
7 63058
On Feb 23, 3:06 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:
Are the following two validation the same:
1) IsNull(Me.ColumnName) and Me.ColumnName = ""
2) Me.ColumnName """

It would seem to be better to use: Me.ColumnName """
No they are not. One tests for a value (empty strings are values) and
the other sees what of two values is logically greater.
An empty string is less than a 'normal' string and a numeric variable
with no value defaults to 0.
However when doing this and one of the values is Null (mainly when
using variants) the comparison will always fail because a null has no
value to test.

I find the easiest test when you need to know if something is null is
to use the Nz function. If it is, this function lets you force a
different value so that your comparison don't fail.

Feb 23 '07 #2
On Feb 23, 2:23 pm, "storrboy" <storr...@sympatico.cawrote:
On Feb 23, 3:06 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:
Are the following two validation the same:
1) IsNull(Me.ColumnName) and Me.ColumnName = ""
2) Me.ColumnName """
It would seem to be better to use: Me.ColumnName """

No they are not. One tests for a value (empty strings are values) and
the other sees what of two values is logically greater.
An empty string is less than a 'normal' string and a numeric variable
with no value defaults to 0.
However when doing this and one of the values is Null (mainly when
using variants) the comparison will always fail because a null has no
value to test.

I find the easiest test when you need to know if something is null is
to use the Nz function. If it is, this function lets you force a
different value so that your comparison don't fail.
What is the recommended syntax to verify if a text box is empty?
I assume you should check for both nulls and empty string.
Does Me.Column "" check for both nulls and empty string?

Feb 23 '07 #3

If Nz(Me!txBoxName,True) Then
or
If Nz(Me!txBoxName,"") = "" then ....
or
variable = Nz(Me!txBoxName,"")

The last argument is what to return if the value is null. Otherwise
the actual value is returned.

Feb 23 '07 #4
On 23 Feb 2007 12:31:53 -0800, "to*******@msn.com" <to*******@msn.comwrote:
>On Feb 23, 2:23 pm, "storrboy" <storr...@sympatico.cawrote:
>On Feb 23, 3:06 pm, "tomleb...@msn.com" <tomleb...@msn.comwrote:
Are the following two validation the same:
1) IsNull(Me.ColumnName) and Me.ColumnName = ""
2) Me.ColumnName """
It would seem to be better to use: Me.ColumnName """

No they are not. One tests for a value (empty strings are values) and
the other sees what of two values is logically greater.
An empty string is less than a 'normal' string and a numeric variable
with no value defaults to 0.
However when doing this and one of the values is Null (mainly when
using variants) the comparison will always fail because a null has no
value to test.

I find the easiest test when you need to know if something is null is
to use the Nz function. If it is, this function lets you force a
different value so that your comparison don't fail.

What is the recommended syntax to verify if a text box is empty?
I assume you should check for both nulls and empty string.
Does Me.Column "" check for both nulls and empty string?
If Len(Me.MyTextBox & "") 0 Then ...

This will catch both Nulls and ZeroLengthStrings in one check.
Wayne Gillespie
Gosford NSW Australia
Feb 24 '07 #5
I use the following code to check for null and empty string:

If Len(Nz(Me!txBoxName,"")) = 0 Then

Feb 24 '07 #6
PrettyCool Wayne!
I hadn't seen that one yet. All with one function

Feb 24 '07 #7
On 23 Feb 2007 16:42:13 -0800, "Ap******@gmail.com" <Ap******@gmail.comwrote:
>PrettyCool Wayne!
I hadn't seen that one yet. All with one function
I think I got it from Lyle from memory.
Wayne Gillespie
Gosford NSW Australia
Feb 24 '07 #8

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

Similar topics

10
by: David Graham | last post by:
Hi I have been busy going through the last weeks postings in an attempt to absorb javascript syntax (I guess it's not possible to just absorb this stuff in a passive way - I'm getting way out of...
7
by: BlueDragon | last post by:
I don't know enough math to demonstrate that any numerical operation with a null should yield a null; although I would guess that it's true. I just don't buy it, however, when dealing with strings...
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...
5
by: VMI | last post by:
How can I validate a null string or an empty string in the same IF statement? If I use this: if (myString.Trim().Length <= 0 || myString == null) { //do stuff } I'll get a run-time error...
4
by: web1110 | last post by:
I have an array of of 5 string elements. I put values in 3 of them. Yet when I loop over them, I do not catch the empty string. The code output below does not include "Empty" stringx=new...
26
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I...
6
by: =?Utf-8?B?QmlsbEF0V29yaw==?= | last post by:
Hi, Thought this would be simple! If I want to validate a field that can contain "z" followed by 3 digits OR it's a completely empty string, how do I do that? The z123 bit is simple, but the empty...
8
by: Joe Kovac | last post by:
Hi! I want the user to edit a textbox which allows following values only: - Time (Format: 23:59, HH:MM) or - NULL (empty string) What can I do, so that this works kinda automatically, meaning...
2
by: Jay | last post by:
I have a SQL Server table with nvarchar type column which has not null constraint. I am inserting empty string ("") from Java to the table column. When I export this table into .csv file using bcp...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...

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.