Results 1 to 4 of 4
  1. #1
    Xarkath is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Millcreek WA
    Posts
    92

    Invalid use of Null??

    Hello,



    I had a small bit of code working last night but today when I resumed testing the form the following line of the code is now throwing the error: Invalid use of Null.

    mbp = DMax("[ID]", "[Invoice Tracking]", "[Finalized Date] Is Not Null" & " AND [Group#]=" & """" & [Forms]![EnrlTracking_frm]![grp#] & """")

    Any ideas why it started throwing that error? What I have found online so far suggests that it is a valid use of Null. And I have not yet made any changes this morning so it seems like it should be working as well today as it did yesterday.

    Is there maybe a better way to write this line of code to simply avoid the error altogether?

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What data type is mbp? Only Variant type variable can hold Null.

    DMax will return Null if no match found.

    mbp = Nz(DMax("[ID]", "[Invoice Tracking]", "[Finalized Date] Is Not Null" & " AND [Group#]=" & """" & [Forms]![EnrlTracking_frm]![grp#] & """"), 0)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    JUNE7 is right. You cant assign Nulls to other datatypes except variants.

  4. #4
    Xarkath is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Millcreek WA
    Posts
    92
    That makes perfect sense. This was my oversight, the group used in the test has not had an invoice ran yet so it did produce a null value.

    Thanks for the help. The people on this forum are AWESOME.

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

Similar Threads

  1. Invalid use of null?
    By snipe in forum Programming
    Replies: 12
    Last Post: 05-12-2015, 04:53 PM
  2. Invalid use of Null
    By hellfire45 in forum Access
    Replies: 12
    Last Post: 04-16-2015, 11:28 AM
  3. Replies: 3
    Last Post: 11-13-2013, 08:56 AM
  4. Invalid use of null
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 03-24-2013, 11:05 PM
  5. Invalid Use of Null!?!
    By Kipster1203 in forum Access
    Replies: 4
    Last Post: 05-13-2010, 06:09 AM

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