Results 1 to 4 of 4
  1. #1
    grahamers is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    3

    Angry "Invalid use Of Null" In Recordset Containing a Memo Field set to Null


    OK this is a strange one.

    In Access 2010 32 bit, I am attempting to open a recordset based on a query and read certain fields in so that I can update a different table.

    While the query contains many fields, the fields I am attempting to manipulate are an ID ("ID") field and a Memo field ("[Description Note]").

    When I read any field from the recordset for a record that contains an empty [Description Note] field, I get an "Invalid use Of Null" error.

    Here is my code:

    Code:
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim sSql As String
        Dim sNote As String
        Dim iPMID as Integer
    
    
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("qryPMs", dbOpenSnapshot)
        Do While Not rst.EOF
            iPMID = rst![ID]                    <------------------------ Code breaks here.
            sNote = rst![Description Note]
        {DO STUFF}        
        rst.MoveNext
        Loop
    if every [Description Note] field has at least one character in it, the code works great. however, if any [Description Note] is empty, then the code breaks as soon as I read any field from that record.

    I have tried changing the type of DAO recordset I am opening and I have tried re-ordering which fields I read first. All to no avail.

    This has to be a common issue, but extensive Googling has turned up nothing.

    Also, I don't know if this matters, but one of the tables in the query I am reading is a linked SharePoint table that contains both fo the fields in question.

    Any thoughts?

    Thanks for any tips in advance!

    -Graham
    Last edited by grahamers; 11-13-2013 at 08:52 AM. Reason: Added DIM statements to my code and SharePoint note.

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Is "iPMID" defined as string or variant?

    String will not accept "Null" but "Variant" will.

  3. #3
    grahamers is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    3
    It is an integer, but the code breaks if I read Description Note first instead of iPMID.

  4. #4
    grahamers is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    3
    Quote Originally Posted by lfpm062010 View Post
    Is "iPMID" defined as string or variant?

    String will not accept "Null" but "Variant" will.
    You are a life saver!

    This fixed it. I changed PMID from Integer to variant and it worked. The odd part was that the code was throwing an error when reading iPMID which was NOT null BEFORE I tried to read the Description Note which was null.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-18-2012, 12:09 PM
  2. Passing criteria "NULL" or "IS NOT NULL" to a query
    By SgtSaunders69 in forum Forms
    Replies: 1
    Last Post: 12-24-2011, 02:22 AM
  3. Replies: 3
    Last Post: 12-20-2011, 08:41 AM
  4. StrComp causing "Invalid use of Null" error
    By sephiroth2906 in forum Programming
    Replies: 5
    Last Post: 09-15-2011, 07:06 PM
  5. Update query from form "invalid use of null"
    By Lady_Jane in forum Programming
    Replies: 4
    Last Post: 08-16-2011, 01:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums