Results 1 to 14 of 14
  1. #1
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    Invalid use of NULL error

    Good Morning

    I have a small data base that I am getting an Invalid use of null error when opening some forms. I just click the "X" and it goes away and the form opens, but it is very annoying. I have attached a copy of the file for your convenience.
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you can either:

    ignore the error with
    on error resume next

    or
    use NZ(field) 'to convert nulls to zero

  3. #3
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    So how do I use NZ(field) 'to convert nulls to zero. Where dim I put this piece of code?

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Interesting. You have some well documented code.

    I am getting an Invalid use of null error when opening some forms.
    Readers will want a little more specifics on
    --which form
    --some guidance on how to reproduce the error.

    I opened your form and selected monthly, weekly,daily without getting an error?????

  5. #5
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    I am using office (Access) 2016 32 bit. The forms I get the error "Invalid use of null" on are "frmCalendar" and frmCanedarAppt". On form frmCalendarWeek I get a "run time error and the following piece of code is noted.

    [CODE]Private Sub Day1Data_Enter()
    vDate =Nz(Me.txtSun) 'savecurrent date in case ENTER key pressed
    End Sub
    [/CODE]

    The line "vDate = Nz(Me.txtSun) 'save current date in case ENTER key pressed" is high lighted in yellow.

    Thank-you.

  6. #6
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    I am using office (Access) 2016 32 bit. The forms I get the error "Invalid use of null" on are "frmCalendar" and frmCanedarAppt". On form frmCalendarWeek I get a "run time error and the following piece of code is noted.

    [CODE]Private Sub Day1Data_Enter()
    vDate =Nz(Me.txtSun) 'savecurrent date in case ENTER key pressed
    End Sub
    [/CODE]

    The line "vDate = Nz(Me.txtSun) 'save current date in case ENTER key pressed" is high lighted in yellow.

    Thank-you.

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    The problem is related to the Openargs variable. It's value is NULL.

    I am not familiar with Allen Browne's code in any detail. I suspect you have copied it and possibly modified it.
    However, if you have copied or customized it, then somewhere there is a missing assignment for Openargs.

    I got the error 94 Invalid use of NULL in frmCalendarAppt in this line

    Code:
    vDateTime = CDate(OpenArgs)                                         'fetch appointment date from OpenArgs
    and since OpenArgs is NULL, it initiates the error.

  8. #8
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Since it is expecting a date, it probably doesn't like the fact that you are supplying a Null value for the date.
    Use the second argument of the NZ and tell it a default date value to use in the case of a Null (like the current date), i.e.
    Code:
    vDate =Nz(Me.txtSun,Date)
    See here for more on NZ: http://www.techonthenet.com/access/f...dvanced/nz.php


    Edit: I just saw Orange's reply. I have not been able to download your database, so he is probably more familiar of the detail of what is going on in it than I am.

  9. #9
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    I downloaded it and have made no changes to the code. What you see is what I got.

  10. #10
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    You may get more info from the source article by Allen Browne.

    I don't use that form/code, so you have what you have. My look at your code shows OpenArgs is NULL, and you can't do a CDate(Openargs) as the code does.

    You know where the error is occurring, so some debugging/testing/reviewing is all I can suggest.

  11. #11
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    How can I run the F8 debud so it goes through one sequence at a time.

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

  13. #13
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    Ok I went to the http://www.cpearson.com/excel/DebuggingVBA.aspx and followed the instruction. At least I think I did. I put the curser on the line to be analyzed and press F8 nothing happens. I pressed Ctrl F8 and I get a message that says "line is not an executable statement. This message popes up no matter which line I try to debug. I tried the Debug menu option and that did not work either. What am I doing wrong in Access. It works fine in Excel.

  14. #14
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I always set a breakpoint (F9 or click next to the statement in the Margin Indicator Bar (if visible)). There will be a redish dot in the margin indicator bar and the code line will have the same color background. When the code execution gets to that point, it will halt.

    Some procedures cannot be executed by pressing the F8 key. For example, a button.You will have to set a breakpoint in the button code, go back to the form and click the button. The debug window should appear; then the F8 key will execute code one line at a time (single step).

    Open Help in the IDE and search for Breakpoint, F8 or F9.

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

Similar Threads

  1. Run time error '94': Invalid Use of Null... help
    By batowl in forum Programming
    Replies: 3
    Last Post: 05-14-2014, 01:58 PM
  2. Replies: 1
    Last Post: 03-22-2013, 09:59 AM
  3. Error 94: Invalid Use of Null
    By athomas8251 in forum Forms
    Replies: 3
    Last Post: 11-09-2011, 11:46 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. DLookUp function giving invalid use of null error
    By shubhamgandhi in forum Programming
    Replies: 4
    Last Post: 07-21-2011, 06:04 PM

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