Results 1 to 5 of 5
  1. #1
    louise is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2015
    Posts
    112

    Query expression using currency fields is not currency in the result

    Hello,


    I have an expression in a query which involves going through assessment value field, covering multiple years, and selecting the most recent one. I get the expected result but it is not a currency field (e.g., I cannot sum the column in datasheet view -- but i can with the component parts).

    I am hoping for some help, my several attempts have failed.
    Below I tried using "FormatCurrency".
    (I assumed an expression with all currency fields would result in the same. Is that false?)


    AssmtMostRecentYr: FormatCurrency(IIf([Assessed-Value2025] Is Not Null,[Assessed-Value2025],IIf([Assessed-Value2024] Is Not Null,[Assessed-Value2024],IIf([Assessed-Value2023] Is Not Null,[Assessed-Value2023],IIf([Assessed-Value2022] Is Not Null,[Assessed-Value2022],IIf([Assessed-Value2021] Is Not Null,[Assessed-Value2021],0))))),2)

    Thanks for any assistance!

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Try CCur(Iif([Assesed-.....) instead.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    FormatCurrency (as well as Format, FormatNumber) returns a string, not an actual number (or date) value. This can be an issue in subsequent calcs using that value.

    Do formatting in report, not query.

    Unless you are converting a string like "15.8332" to a number, I don't see any reason to use it. The result of CCur("15.8332") is 15.8332.

    Consider:

    Switch([Assessed-Value2025] Is Not Null,[Assessed-Value2025], [Assessed-Value2024] Is Not Null,[Assessed-Value2024], [Assessed-Value2023] Is Not Null,[Assessed-Value2023], [Assessed-Value2022] Is Not Null,[Assessed-Value2022], [Assessed-Value2021] Is Not Null,[Assessed-Value2021], True,0)

    Could wrap that expression with Round() but be aware it uses even/odd banker's rounding.
    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.

  4. #4
    louise is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2015
    Posts
    112
    Thank you, Gicu.
    That was precisely what I needed! I have never seen this function before and I'm going to remember it!

    June7, thank you for your feedback too. I wanted to actually change/(maintain) the field as a currency type that I can download as a query and use in other calculations -- not just display it differently, so will go with CCur.

    Thanks, both

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You're very welcome Louise!
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Need Currency format for expression...
    By bonnielynnw in forum Reports
    Replies: 5
    Last Post: 06-15-2018, 11:11 AM
  2. Replies: 1
    Last Post: 01-21-2016, 05:38 PM
  3. Currency fields and if to get true/false
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 09-29-2013, 07:40 PM
  4. Format two fields in a Union Query as Currency
    By alansidman in forum Queries
    Replies: 1
    Last Post: 12-14-2012, 12:41 PM
  5. Replies: 2
    Last Post: 03-23-2011, 11:43 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