Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2019
    Posts
    1,061

    Crosstab query -- replaced NULL values with 0 (zeros) but replacement values are stored as text

    Hi:

    Please see attached sample DB (as well screenshot).

    The default crosstab includes NULL values for n records. I changed the [COUNT] crosstab's SUM value to an expression as follows:
    Code:
    CountStatus: Format(Nz(Sum(Val([Count])),0))
    As illustrated, while I now display "zero" (0) values, they are stored as TEXT (vs. NUMBER) even though the expression includes the "Val" reference.

    How should the expression be changed so that I still get zeros for missing values but they are stored as a NUMBER (vs. TEXT)?



    Thank you,
    EEH
    Attached Thumbnails Attached Thumbnails Crosstab.png  
    Attached Files Attached Files

  2. #2
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    172
    Quote Originally Posted by skydivetom View Post
    Hi:

    Please see attached sample DB (as well screenshot).

    The default crosstab includes NULL values for n records. I changed the [COUNT] crosstab's SUM value to an expression as follows:
    Code:
    CountStatus: Format(Nz(Sum(Val([Count])),0))
    As illustrated, while I now display "zero" (0) values, they are stored as TEXT (vs. NUMBER) even though the expression includes the "Val" reference.

    How should the expression be changed so that I still get zeros for missing values but they are stored as a NUMBER (vs. TEXT)?

    Thank you,
    EEH
    Remove the Format() part. Specify the field types in the query. Format returns a string if I remember correctly.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,446
    The format function changes values to text. Just remove it and leave the nz function

  4. #4
    Join Date
    Feb 2019
    Posts
    1,061
    I changed the expression to:

    CountStatus: Nz(Sum(Val([Count])),0)

    Unfortunately, they values still come out as text. See attached screenshot.

    Any other ideas??
    Attached Thumbnails Attached Thumbnails Crosstab2.png  

  5. #5
    Join Date
    Feb 2019
    Posts
    1,061
    I swapped the "Val" before the NZ... that did the trick!

    CountStatus: Val(Nz(Sum([Count]),0))
    Attached Thumbnails Attached Thumbnails Crosstab3.png  

  6. #6
    Join Date
    Feb 2019
    Posts
    1,061
    Thank you both for the recommendation to remove the Format()... I appreciate it.

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,446
    why do you need the Val function? - count returns a number, not text

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

Similar Threads

  1. Crosstab Query Showing Null Values
    By equestrian in forum Queries
    Replies: 2
    Last Post: 09-22-2015, 03:24 AM
  2. Crosstab Query Values Export as Text
    By Paul H in forum Queries
    Replies: 0
    Last Post: 01-07-2013, 11:18 AM
  3. Replies: 1
    Last Post: 12-15-2011, 04:44 AM
  4. Addup and Replacement values query
    By desp in forum Access
    Replies: 1
    Last Post: 10-17-2011, 06:17 AM
  5. Displaying multiple text values in crosstab query
    By MFlood7356 in forum Queries
    Replies: 6
    Last Post: 06-28-2011, 11:30 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