Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2019
    Posts
    1,103

    SQL query output has missing decimal for "integer"

    Hello,

    I have the following VBA SQL query:



    Code:
                        strSQL = "SELECT Q100_Scoring_Input.TIER_1_ID_H, Q100_Scoring_Input.HYPOTHESES_H, " & _
                                 "ROUND(Avg(Q100_Scoring_Input.[" & strModel & "_SCORE]), 1) AS [AVG_" & strModel & "_SCORE] " & _
                                 "FROM Q100_Scoring_Input " & _
                                 "GROUP BY Q100_Scoring_Input.TIER_1_ID_H, Q100_Scoring_Input.HYPOTHESES_H " & _
                                 "ORDER BY ROUND(Avg(Q100_Scoring_Input.[" & strModel & "_SCORE]), 1) DESC;"

    The output currently appears as follows:
    Code:
    5.7
    5.2
    5
    4.8
    4.2
    4
    However, I need all values to consistently display with one decimal place, like this:
    Code:
    5.7
    5.2
    5.0
    4.8
    4.2
    4.0
    I have attempted various formatting options. In some cases, integers were correctly displayed as "5.0" and "4.0," but this changed the data type to text (causing left-alignment in the query output).

    How can I ensure the output remains numeric while consistently displaying one decimal place, including for whole numbers?

    Thanks in advance for your help!

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    can you use the Format "0.0"

  3. #3
    Join Date
    Feb 2019
    Posts
    1,103
    I tried that... output was 'text'.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I would probably format it in the form or report the query is being used for.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    where are you ouputting it? report/form?
    if on those two you can control the Alignment of
    that column (textbox) on design view (Text Align property).

  6. #6
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    You must format it in the form or report the query is being used for.

  7. #7
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,180
    You never show data in tables or query results to the user, you use forms or reports for this, so there is little point doing formatting in a query, is there?

  8. #8
    Join Date
    Feb 2019
    Posts
    1,103
    No feasible solution provided... closing thread.

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

Similar Threads

  1. Replies: 2
    Last Post: 01-06-2021, 10:58 AM
  2. Convert decimal comma to decimal point
    By Hans Karlsson in forum Programming
    Replies: 3
    Last Post: 06-30-2014, 01:56 PM
  3. Replies: 7
    Last Post: 04-23-2013, 11:57 AM
  4. Adding column as INTEGER makes it a long integer?
    By luckycharms in forum Programming
    Replies: 2
    Last Post: 10-20-2010, 02:47 PM
  5. Replies: 1
    Last Post: 06-09-2006, 05:44 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