Results 1 to 12 of 12
  1. #1
    pmjewett is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    6

    Why is Nz Function in expression converting my data to a string?

    Hello,



    I don't have a lot of experience with Access and I'm having trouble determining the results received from a field expression that is using the NZ function. The expression is M-BEGIN INVENT: Nz([current.begin invent],0) where "current.begin invent" is datatype "number" in the source table. The issue is that this expression is leaving the format of the field as a "string" so when exported to Excel it must be converted back in order to run mathematical calculations on the results.

    Trying to read up on this but not getting anywhere.

    Any assistance would be greatly appreciated!

    Thanks

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    It's a coercive type conversion. Which could be interpreted as a bug . Try Adding 0 to your result

    Code:
     M-BEGIN INVENT: Nz([current.begin invent],0)+0
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Also try putting the field itself in []
    Code:
    M-BEGIN INVENT: Nz([current].[begin invent],0)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    pmjewett is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    6
    "It's a coercive type conversion. Which could be interpreted as a bug . Try Adding 0 to your result"
    Weird. That appeared to work however the values in the filed are "invisible" and only appear when I click on them. See attached screenshot.Click image for larger version. 

Name:	access issue.jpg 
Views:	23 
Size:	206.3 KB 
ID:	34129

  5. #5
    pmjewett is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    6
    "Also try putting the field itself in []"

    Hi, This unfortunately had no effect. Still getting a string. Thanks though.

  6. #6
    pmjewett is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    6
    Dupe response.
    Attached Thumbnails Attached Thumbnails access issue.jpg  

  7. #7
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    It's a coercive type conversion. Which could be interpreted as a bug
    I don't know if I would call it a "bug". It is just more understanding how it works, and what it returns.

    pmjewettm,
    If you cannot see it, how do you know it is still a string?
    Can you post the SQL code of your query?

  8. #8
    pmjewett is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    6
    JoeM,

    Screwed up my responses on this thread..apologies. Below clarification...
    M-BEGIN INVENT: Nz([current.begin invent],0)+0 (This works but the values in the field are "hidden" and only visible when I click on them.
    I know this correctly leaves them as numbers because they are right-justified and when right-clinking on the field I get the "numbers filter" in the contextual filter.

    However my colleague just tried flipping the order of operation on the above...
    M-BEGIN INVENT: 0+Nz([current.begin invent],0)





    and that worked. Meaning correctly numbers now AND visible. Weird

    pmjewettm,

    If you cannot see it, how do you know it is still a string?
    Can you post the SQL code of your query?[/QUOTE]

  9. #9
    pmjewett is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    6
    Spoke too soon. Changing the order of operation 0+ Nz([current.begin invent],0) still leaves me with an "invisible field" that I can only see when I click on it.

    Quote Originally Posted by pmjewett View Post
    JoeM,

    Screwed up my responses on this thread..apologies. Below clarification...
    M-BEGIN INVENT: Nz([current.begin invent],0)+0 (This works but the values in the field are "hidden" and only visible when I click on them.
    I know this correctly leaves them as numbers because they are right-justified and when right-clinking on the field I get the "numbers filter" in the contextual filter.

    However my colleague just tried flipping the order of operation on the above...
    M-BEGIN INVENT: 0+Nz([current.begin invent],0)





    and that worked. Meaning correctly numbers now AND visible. Weird

    pmjewettm,

    If you cannot see it, how do you know it is still a string?
    Can you post the SQL code of your query?
    [/QUOTE]

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    I confess to be somewhat bemused by this thread but suggest you try 'forcing' a number value using CInt or Clng or CSng or CDbl depending on the type of number you will have. Doing that means you can remove the +0 component again.

    e.g. CInt(Nz([current].[begin invent],0))
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just so you are aware,

    you should NOT use spaces in object names. (Better options are "BeginInvent" or "Begin_Invent")

    "Current" is a reserved word in Access and shouldn't be used for object names. Plus it is not very descriptive.

  12. #12
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I don't think the "hidden" think has anything to do with the calculation itself, but you may have something else going on there (what kind of Formatting do you have on this field?).

    See if you can create a new database, with a stripped down version of the problem.
    Then if the problem still exists, upload the database for analysis.
    If the problem does not exist, then you know that the "hidden" issue has nothing to do with your calculation.

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

Similar Threads

  1. Replies: 6
    Last Post: 06-20-2016, 01:29 PM
  2. Converting a text string to its ASCII value
    By Access_Novice in forum Access
    Replies: 4
    Last Post: 03-19-2015, 10:28 PM
  3. Replies: 7
    Last Post: 12-26-2014, 12:17 PM
  4. Converting a string to date/time
    By RayMilhon in forum Programming
    Replies: 8
    Last Post: 09-28-2012, 10:02 AM
  5. Converting/Viewing OLE Data as String...
    By oldgem in forum Access
    Replies: 0
    Last Post: 09-12-2009, 06:35 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