Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Apparently, between the crosstabs and UNION, all data is converted to text which can't be summed or averaged. I tried using CInt to convert values back to number but CInt can't handle the nulls and empty strings in field. I can get this much to work:



    Select Command, Commander, Inspector, CDbl(Nz(FSL,0)) AS FSLCt, InspCt, Total, FSL0, FSL1, FSL2, FSL3, FSL4
    From [Q_Ratio_D1_Avg_Comm_Crosstab]
    UNION Select Command, Commander, Inspector, CDbl(Nz(Total_Insp,0)), Blank, Number, FSL0, FSL1, FSL2, FSL3, FSL4
    From [Q_Ratio_D1_Avg_Comm_Insp_Crosstab];

    Trying to use CDbl and Nz on InspCt, Total, Blank, Number fields causes type mismatch error. Maybe because in the crosstabs InspCt, Blank, Number are calculated as empty string. Why? Use Null and then the CDbl an Nz functions should work on these fields as well.

    So glad I don't have need for crosstab queries!
    Last edited by June7; 11-07-2012 at 01:29 PM.
    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.

  2. #17
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    Maybe I uploaded the wrong db. I renamed it and reuploaded it. The Querie name is Q_Ratio_Avg_Union
    Attached Files Attached Files

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Ooops! You must have seen my post before I edited it. I accidentally opened the old db after downloading the revision in post 15. I did the edit within 5 minutes of original posting (and a minor edit this AM).

    Review my last post again.
    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. #19
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    To use Null would it look like Blank: "" rather than Blank: " "? If not how do you make it Null?

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    An empty string is:
    Blank: ""

    This is a space (which Access probably trims so the result is empty string):
    Blank: " "

    This is a field with Null value:
    Blank: Null

    I don't allow empty strings in tables and would never calculate a field as empty string.
    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.

  6. #21
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    Changing it gives me a "Data type mismatch" in the union query. The other queries work fine. I even went back to my old union query and got the data mismatch error.

  7. #22
    Huddle is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Jun 2010
    Posts
    318
    SUCCESS!!!! I turned one of the crosstab queries into a select querie. Replaced the Null with zeros. Went back to my old Union formula. Everything transferred right and now works.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 12-05-2011, 04:53 AM
  2. Counting Detail Records by Group
    By Paul H in forum Reports
    Replies: 7
    Last Post: 10-21-2011, 02:53 PM
  3. Trouble counting items in a report
    By Walt Stypinski in forum Access
    Replies: 2
    Last Post: 06-13-2011, 08:21 PM
  4. Report Help: counting and average
    By alliandrina in forum Reports
    Replies: 0
    Last Post: 03-08-2011, 01:24 PM
  5. Replies: 1
    Last Post: 11-11-2006, 08:00 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