Null Null Null!!!!!!!!! 
Author Message
 Null Null Null!!!!!!!!!

Hi all
I am a bit frustated with this bussiness of the Null value messing me up
every time I try to retrieve a record from a Table variable and assing
the values of the fields to some Text boxes which are not bound to
any control.  The only way I get to avoid this is to have a million
if statements like
if IsNull(myTable("[my field]") then
  my_Text_Box.Text = ""
else
  my_Text_Box.Text = myTable("[my field]")
end If

Is there a better, more elegant, quicker way of doing this?

Please Let me know!!!
Thanks for you advice

Jose R, Nebro



Sat, 28 Jun 1997 11:31:36 GMT  
 Null Null Null!!!!!!!!!

Quote:

>Hi all
>I am a bit frustated with this bussiness of the Null value messing me up
>every time I try to retrieve a record from a Table variable and assing
>the values of the fields to some Text boxes which are not bound to
>any control.  The only way I get to avoid this is to have a million
>if statements like
>if IsNull(myTable("[my field]") then
>  my_Text_Box.Text = ""
>else
>  my_Text_Box.Text = myTable("[my field]")
>end If
>Is there a better, more elegant, quicker way of doing this?

Hi Jose,
My_Text_Box.Text = mydata & ""

------------------------------------------------------------------------
Chuck Stuart
Mesquite TX USA
Contract Programmer.
Author of VBTrace, runtime VB Trace/Profile/XRef utility.
------------------------------------------------------------------------



Sat, 28 Jun 1997 07:21:38 GMT  
 Null Null Null!!!!!!!!!

Quote:

>I am a bit frustated with this bussiness of the Null value messing me up
>every time I try to retrieve a record from a Table variable and assing
>the values of the fields to some Text boxes which are not bound to
>any control.  The only way I get to avoid this is to have a million
>if statements like
>if IsNull(myTable("[my field]") then
>  my_Text_Box.Text = ""
>else
>  my_Text_Box.Text = myTable("[my field]")
>end If

How 'bout....

        my_Text_Box.Text = myTable("[my field]") & ""

--
Luke Webber

* Note: The opinions expressed by Luke Webber are in no way supported *
*       by his employers, Luke Webber Consulting Services             *



Mon, 07 Jul 1997 18:08:53 GMT  
 Null Null Null!!!!!!!!!

Quote:

>Hi all
>I am a bit frustated with this bussiness of the Null value messing me up
>every time I try to retrieve a record from a Table variable and assing
>the values of the fields to some Text boxes which are not bound to
>any control.  The only way I get to avoid this is to have a million
>if statements like
>if IsNull(myTable("[my field]") then
>  my_Text_Box.Text = ""
>else
>  my_Text_Box.Text = myTable("[my field]")
>end If

>Is there a better, more elegant, quicker way of doing this?

The only other way i've came up with is to use the immediate IF Statement
like this:

my_Text_Box.Text = IIF(IsNull(myTable("[my field]")),"",myTable("[my field]"))

which is not that much better but it's on a single line !!! Wow !!!

I'm affraid there's nothing you can do about it since it is not possible
to assing a #NULL# to a text field.  Another way which implies a little more
design is to ensure you always store a value (even an empty string "") to each
fields in your DB, assuming that you don't use an existing database with
loaded data...

Good Luck,

Alain.



Tue, 08 Jul 1997 14:21:54 GMT  
 Null Null Null!!!!!!!!!

Quote:

> >Hi all
> >I am a bit frustated with this bussiness of the Null value messing me up
> >every time I try to retrieve a record from a Table variable and assing
> >the values of the fields to some Text boxes which are not bound to
> >any control.  The only way I get to avoid this is to have a million
> >if statements like
> >if IsNull(myTable("[my field]") then
> >  my_Text_Box.Text = ""
> >else
> >  my_Text_Box.Text = myTable("[my field]")
> >end If

> >Is there a better, more elegant, quicker way of doing this?
> The only other way i've came up with is to use the immediate IF Statement
> like this:
> my_Text_Box.Text = IIF(IsNull(myTable("[my

field]")),"",myTable("[my field]"))

Quote:
> which is not that much better but it's on a single line !!! Wow !!!
> I'm affraid there's nothing you can do about it since it is not possible
> to assing a #NULL# to a text field.  Another way which implies a little more
> design is to ensure you always store a value (even an empty string
"") to each
> fields in your DB, assuming that you don't use an existing database with
> loaded data...

I use a function as follows whenever I can't tolerate a null value.

Function ConvertNulls (value, default) As Variant

    If IsNull(value) Or IsEmpty(value) Then
        ConvertNulls = default
    Else
        ConvertNulls = value
    End If

End Function

Then all you need to do is:
my_Text_Box.Text = ConvertNulls(myTable("[my field]"),"")--
Regards


Lerwick, Shetland, UK     Compuserve: 100016,1727
Phone: +44 1595 695762           Fax: +44 1595 694459
=================================================================



Tue, 08 Jul 1997 19:56:50 GMT  
 Null Null Null!!!!!!!!!


Quote:

> >Hi all
> >I am a bit frustated with this bussiness of the Null value messing me up
> >every time I try to retrieve a record from a Table variable and assing
> >the values of the fields to some Text boxes which are not bound to
> >any control.  The only way I get to avoid this is to have a million
> >if statements like
> >if IsNull(myTable("[my field]") then
> >  my_Text_Box.Text = ""
> >else
> >  my_Text_Box.Text = myTable("[my field]")
> >end If

Use this for each field instead:

  my_Text_Box.Text = mytable("[myfield]") & ""

It's much more compact.

Cheers.



Fri, 11 Jul 1997 12:31:45 GMT  
 Null Null Null!!!!!!!!!
To avoid "Invalid Use Of Null", just append a null string to the record.
MyData = Data1.Recordset & ""
------------------------------------------------------------------------
Chuck Stuart
Mesquite TX USA
Contract Programmer.
Author of VBTrace, runtime VB Trace/Profile/XRef utility.
------------------------------------------------------------------------


Tue, 08 Jul 1997 21:12:28 GMT  
 Null Null Null!!!!!!!!!

: > >
: > >Hi all
: > >I am a bit frustated with this bussiness of the Null value messing me up
: > >every time I try to retrieve a record from a Table variable and assing
: > >the values of the fields to some Text boxes which are not bound to
: > >any control.  The only way I get to avoid this is to have a million
: > >if statements like
: > >if IsNull(myTable("[my field]") then
: > >  my_Text_Box.Text = ""
: > >else
: > >  my_Text_Box.Text = myTable("[my field]")
: > >end If
: > >
: > >Is there a better, more elegant, quicker way of doing this?

: > The only other way i've came up with is to use the immediate IF Statement
: > like this:

: > my_Text_Box.Text = IIF(IsNull(myTable("[my
: field]")),"",myTable("[my field]"))

: > which is not that much better but it's on a single line !!! Wow !!!

: > I'm affraid there's nothing you can do about it since it is not possible
: > to assing a #NULL# to a text field.  Another way which implies a little more
: > design is to ensure you always store a value (even an empty string
: "") to each
: > fields in your DB, assuming that you don't use an existing database with
: > loaded data...

: I use a function as follows whenever I can't tolerate a null value.

: Function ConvertNulls (value, default) As Variant

:     If IsNull(value) Or IsEmpty(value) Then
:         ConvertNulls = default
:     Else
:         ConvertNulls = value
:     End If

: End Function

: Then all you need to do is:
: my_Text_Box.Text = ConvertNulls(myTable("[my field]"),"")--
: Regards


: Lerwick, Shetland, UK     Compuserve: 100016,1727
: Phone: +44 1595 695762           Fax: +44 1595 694459
: =================================================================

How about this:

    text1 = recordset1.fields("thefieldname") & ""

it works for me!



Mon, 14 Jul 1997 06:10:20 GMT  
 Null Null Null!!!!!!!!!

: > >
: > >Hi all
: > >I am a bit frustated with this bussiness of the Null value messing me up
: > >every time I try to retrieve a record from a Table variable and assing
: > >the values of the fields to some Text boxes which are not bound to
: > >any control.  The only way I get to avoid this is to have a million
: > >if statements like
: > >if IsNull(myTable("[my field]") then
: > >  my_Text_Box.Text = ""
: > >else
: > >  my_Text_Box.Text = myTable("[my field]")
: > >end If
: > >

: > which is not that much better but it's on a single line !!! Wow

An easy solution is to to trap the error with On error statement like so:
text1 = ""
text2 = ""
On error Resume next
text1 = Mytable("field1")
text2 = Mytable("field2")
on error ....



Wed, 23 Jul 1997 04:35:23 GMT  
 Null Null Null!!!!!!!!!
Hi All,

Quote:
> Hi all I am a bit frustated with this bussiness of the Null
> value messing me up every time I try to retrieve a record from a
> Table variable and assing the values of the fields to some Text
> boxes which are not bound to any control.

The solution is use for this problem is as follows...

dfField.Text = ds("Field") & ""

The trick is in the '& ""' part of the statement. Appending an empty
string converts the 'Null' value to an empty string and that way you will
not get an error that you are trying to assign a Null value.

Good Luck...

Bye, Jan

Jan G.P. Sijm
Fidonet  : 2:280/410.14



Thu, 24 Jul 1997 22:05:54 GMT  
 Null Null Null!!!!!!!!!
Try

text1 = Mytable("field1") & ""
text2 = Mytable("field2") & ""

This way it doesnt matter whats in your database

By the way, I picked up this trick in this newsgroup

Have Fun
Robby



Fri, 25 Jul 1997 09:39:05 GMT  
 Null Null Null!!!!!!!!!

writes:

Quote:

> : > >
> : > >Hi all
> : > >I am a bit frustated with this bussiness of the Null value messing me up
> : > >every time I try to retrieve a record from a Table variable and assing
> : > >the values of the fields to some Text boxes which are not bound to
> : > >any control.  The only way I get to avoid this is to have a million
> : > >if statements like
> : > >if IsNull(myTable("[my field]") then
> : > >  my_Text_Box.Text = ""
> : > >else
> : > >  my_Text_Box.Text = myTable("[my field]")
> : > >end If
> : > >

> : > which is not that much better but it's on a single line !!! Wow

> An easy solution is to to trap the error with On error statement like so:
> text1 = ""
> text2 = ""
> On error Resume next
> text1 = Mytable("field1")
> text2 = Mytable("field2")
> on error ....

Or... do as we had to, define a function to do nulls

function donull (a as string)
  if isnull(a) then
    donull=""
  else
    donull=a
  endif
end donull

then...

my_textbox.text=donull(mytable([field]))



Sun, 27 Jul 1997 09:58:49 GMT  
 Null Null Null!!!!!!!!!

Quote:


>writes:

>> : > >
>> : > >Hi all
>> : > >I am a bit frustated with this bussiness of the Null value messing me up
>> : > >every time I try to retrieve a record from a Table variable and assing
>> : > >the values of the fields to some Text boxes which are not bound to
>> : > >any control.  The only way I get to avoid this is to have a million
>> : > >if statements like
>> : > >if IsNull(myTable("[my field]") then
>> : > >  my_Text_Box.Text = ""
>> : > >else
>> : > >  my_Text_Box.Text = myTable("[my field]")
>> : > >end If
>> : > >

>> : > which is not that much better but it's on a single line !!! Wow

>> An easy solution is to to trap the error with On error statement like so:
>> text1 = ""
>> text2 = ""
>> On error Resume next
>> text1 = Mytable("field1")
>> text2 = Mytable("field2")
>> on error ....

>Or... do as we had to, define a function to do nulls

>function donull (a as string)
>  if isnull(a) then
>    donull=""
>  else
>    donull=a
>  endif
>end donull

>then...

>my_textbox.text=donull(mytable([field]))

 The simplest method I have found is:
my_Text_Box.Text = myTable("[my field]") & ""

by adding the field with an empty string if is is null you get an empty
string and if you have a value nothing gets added on. If the field is a number
then use:
my_Text_Box.Text = Str$(Val(myTable("[my field]") & ""))

--
--
                            ////

-----------------------oOO--(_)--OOo------------



Wed, 30 Jul 1997 05:06:57 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. Null, Null, Null!

2. double null question [2 * Null = Null] !!!

3. Alter Table with NULL/NOT NULL options

4. Null = Null Not Working ?

5. Null = Null error

6. null in vb and null in sql7

7. null not null

8. When is Null not Null

9. How can I pass NULL value to WinAPI which is expecting a NULL pointer

10. IS NULL vs = NULL - ODBC Drivers

11. To Null, or not to Null...?

12. Sending null strings and NULL values

 

 
Powered by phpBB® Forum Software