Can't MsgBox a simple Access 'TEXT' variable ?

Can't MsgBox a simple Access 'TEXT' variable ?

Post by brad » Thu, 02 May 2002 18:09:12



Hello,
When i read in a TEXT value from access (that doesn't contain any text) i
can't display it in VB. It gives a run-time of "Invalid use of null". Yet
when i test this var for null - it says its NOT NULL. Can anyone help?

  If (oRS.Fields("clFName") = Null) Then
    MsgBox "its null"
  Else
    MsgBox "not null"
  End If

  MsgBox CStr(oRS.Fields("clFName"))   <-- RUN-TIME ERROR HERE !?!

PS. It DOES work ok when there's text in it

brad.

 
 
 

Can't MsgBox a simple Access 'TEXT' variable ?

Post by Mark Jerd » Thu, 02 May 2002 20:51:17


Brad -- Have you tried the old trick of smashing a "" against it?

   MsgBox CStr("" & oRS.Fields("clFName"))

HTH

   -- Mark


Quote:> Hello,
> When i read in a TEXT value from access (that doesn't contain any text) i
> can't display it in VB. It gives a run-time of "Invalid use of null". Yet
> when i test this var for null - it says its NOT NULL. Can anyone help?

>   If (oRS.Fields("clFName") = Null) Then
>     MsgBox "its null"
>   Else
>     MsgBox "not null"
>   End If

>   MsgBox CStr(oRS.Fields("clFName"))   <-- RUN-TIME ERROR HERE !?!

> PS. It DOES work ok when there's text in it

> brad.


 
 
 

Can't MsgBox a simple Access 'TEXT' variable ?

Post by brad » Fri, 03 May 2002 01:15:00


After MANY hours of work, I've finally found the answer.

You have to have both the 'Required' and 'Allow Zero Length' field
properties in Access set to 'true'.

Unbilievable!!
Hehe.
brad.


Quote:> Hello,
> When i read in a TEXT value from access (that doesn't contain any text) i
> can't display it in VB. It gives a run-time of "Invalid use of null". Yet
> when i test this var for null - it says its NOT NULL. Can anyone help?

>   If (oRS.Fields("clFName") = Null) Then
>     MsgBox "its null"
>   Else
>     MsgBox "not null"
>   End If

>   MsgBox CStr(oRS.Fields("clFName"))   <-- RUN-TIME ERROR HERE !?!

> PS. It DOES work ok when there's text in it

> brad.