Re: Invalid Use of Null Error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Graham Mandeno (Graham.Mandeno_at_nomail.please)
Date: 06/17/04


Date: Fri, 18 Jun 2004 10:56:57 +1200

Hi Josef

You have two options:

1. Make your variables of type Variant. A Variant is the only data type
that can hold a Null value. Only do this if you want to distinguish between
Nulls and empty strings, because Variants are less efficient to process.

2. Use the Nz function to convert Nulls to empty strings:
        stGender = Nz ( rst ( "Gender" ), "" )

-- 
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Josef" <jvelardi@hotmail.com> wrote in message
news:MPG.1b3cc1469c9e0b5498969c@news.microsoft.com...
>
> hi,
>
> i am trying to get data from a record set. some fields are null and when
> i try to use this data i get an 'Invalid Use of Null' Error.
>
> ----- Code Snippet -----
>
> Set dbs = CurrentDb()
> strSQL = "SELECT * FROM tbl_STUDENT;"
> Set rst = dbs.OpenRecordSet(strSQL)
>
> While (Not rst.EOF)
>
>     stSudentID = rst("Student ID")
>     stFName = rst("First Name")
>     stMName = rst("Middle Name")
>     stLName = rst("Family Name")
>     stGender = rst("Gender")
>     stDOB = rst("DOB")
>
>     ....
>
>     rst.MoveNext
>
> WEnd
>
> ----------------------
>
> any suggestions on how i can test for Null, or use a different routine
> to get the data from the record set.
>
> many thx.
>


Relevant Pages

  • Re: Text as argument to Randomize function
    ... the Randomize function. ... The VBA Help says that the argument is of type Variant, ... understand it - includes strings. ...
    (microsoft.public.vb.general.discussion)
  • Re: Invalid Use of Null Error
    ... Josef wrote: ... >i am trying to get data from a record set. ... If they were Variant, then you could assign Null values to ... MVP ...
    (microsoft.public.access.formscoding)
  • Re: DB null value returned by TDataSets FieldValues
    ... property to a variant and test the variant. ... where V is of type Variant. ... Bill Todd (TeamB) ... Prev by Date: ...
    (borland.public.delphi.database.ado)