Results 1 to 12 of 12
  1. #1
    Mike51 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    7

    NZ function not working in Access2010 when updating OS from W7 to W10

    Hi, We are updating our company users from Windows 7 to 10 and in testing we discovered that queries that work fine on W7 yeild an error message: "Undefined function in Nz expression" I just set up a new Access2010
    query
    on W10 and used an NZ function as in a common query we use but got still this message when I ran it. Saved the query and opened Access on a W7 box and ran the same query with no squawks. Thanks for guidance

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    That error is often a reference problem. Check them in the VBA editor, Tools/References, see if any are marked Missing.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ashraf is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    37
    Hi Mike51,
    System type can be a reason for such error; moving from 32-bit to 64-bit for windows or for office required to check the references as pbaldy said.
    This is a helpful link to Check
    Also for similar case Check Josh Black reply.

  4. #4
    Mike51 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    7
    Thanks. No references marked missing and the noted references in the link ashraf recommended were all checked. Still selected ok , debug, compile and continued to get the undefined function in nz expression error.

    The other link, though similar, is not the same issue, I believe. One suggestion we received was to change Nz([table[.[field]) expression to iif([table].[field] Is Null,0,[table].[field]). This works but we would prefer to avoid changing a number of queries. I am using a 64-bit machine for W7 and W10. Using same Access2010 db, we do not get the undefined function error message in w7 but do in w10.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Just so we're clear, you checked references on a Win 10 machine that was failing? One option you could try is creating your own Nz() function using the IIf() or an If/Then block. That should mean you don't have to change the Nz() function in the various places that use it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Mike51 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    7
    Yes, Checked references in the Win 10 machine that is failing. (Also checked on an alternate machine just to be sure it was not a specific machine issue.) Sorry, I am not sure how to create my own Nz() function using the substitute IIf() or an If/Then block. I can check with a local developer and will let you know if this works. i am still puzzled why the change in the OS if affecting it and whether upgrading to Access2016 may resolve it.

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    I presume the tables you are querying are access tables and not sql server or other where nz is not a recognised function

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by Mike51 View Post
    Yes, Checked references in the Win 10 machine that is failing. (Also checked on an alternate machine just to be sure it was not a specific machine issue.) Sorry, I am not sure how to create my own Nz() function using the substitute IIf() or an If/Then block. I can check with a local developer and will let you know if this works. i am still puzzled why the change in the OS if affecting it and whether upgrading to Access2016 may resolve it.
    It is odd; usually a reference problem causes this. Creating your own wouldn't be hard; post back if you need help with it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Mike51 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    7
    Thanks Paul. I am not code writer at all....but I welcome your offer for assistance and will likely pass on your suggestion to an associate if will likely be able to follow it. I would prefer a "global" fix rather that needing to hunt for every query and rewrite functions one at a time.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quick and dirty (put in a standard module):

    Code:
    Public Function Nz(varValue As Variant, varReplace As Variant) As Variant  
      If IsNull(varValue) Then
        Nz = varReplace
      Else
        Nz = varValue
      End If
    End Function
    since somebody will chime in with a one-liner I'll give you that too:

    Nz= IIf(IsNull(varValue), varReplace, varValue)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Mike51 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    7
    Thanks Paul, will give this a try and advise results.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem, post back if you still have trouble. I tested that and it worked as expected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Public variable not updating for each function
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 08-28-2014, 06:26 PM
  2. NOW() Function not updating into table
    By joycesolomon in forum Programming
    Replies: 7
    Last Post: 08-13-2014, 06:17 PM
  3. Replies: 7
    Last Post: 03-02-2014, 08:47 PM
  4. Replies: 3
    Last Post: 01-29-2013, 04:34 AM
  5. Updating listbox rowsource not working
    By j2curtis64 in forum Forms
    Replies: 13
    Last Post: 12-07-2011, 01:46 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