Results 1 to 8 of 8

Thread: NULL Field Error

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation

    How can I read a NULL field from ACCESS into
    a control in VB without getting Run Time
    Error 94 (Invalid use of Null).

    Example: Text1 = !Field1
    When Field1 is 'empty' I get Run Time Error 94.




    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Location
    Fort Lauderdale, FL USA
    Posts
    112
    If not isNull(!Field1) Then
    Text1 = !Field1
    End if
    Damonous

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Wink

    Worked PERFECT. Thanks damonous!
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  4. #4
    Guest

    or you could try

    text1 = "" & !Field1

    I don't trust the IsNull function, have had problems with it before.

    VBs handling of null values is absolutely rubbish. Null can in fact be a perfectly accepted value.

    e.g.

    An inventory product; if quantity = null it generally means the product has never been held in stock, whereas quantity = 0 means that it is held in stock but currently there are none on hand.

    This really bugs me....specially when you have to convert from other databases that can handle it ok.

    Thats my moan for today.

  5. #5
    Member
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    39
    I agree with Jethro.
    I've written a function to check Null values as shown..

    Private Function CheckNull(ByVal AValue as Variant) As Variant
    if IsNull(AValue) Then
    CheckNull = AValue
    Else
    CheckNull = ""
    Endif
    End Function

    When I run my program it gives me some error message regarding NULL values... But the strange thing if i debug(F8) the program step by step NO ERRORS..


    ThOmaS TaN

  6. #6
    Guest
    Hello All,

    I use this little trick:
    Code:
    Text1 = !Field1 & ""
    It works like a charm.

    Best,

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Wink

    Very smart trick Rogers!!!
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'speaking of tricks..here's another rs = recordset

    Text1 = Format(rs("yourfieldname"))
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width