Results 1 to 3 of 3
  1. #1
    RobertIngles is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    5

    Crosstab column does not appear if no data to display

    Hi all;



    I have three queries:
    1. Select query (from source table) to display 'UserName' 'Project' 'Hours Worked' and the 'Date' the hours were worked. Also linked to a table that indicates if the 'Date' falls into 'Week 1', 'Week 2', 'Week 3' or 'Week 4' of the month.

    2. Crosstab of #1 displaying Username and Project as rows, Week 1, 2, 3, and 4 as the coumns and total of hours as the value.

    3. Crosstab of #2 that displays a count of the users who have worked hours over the forecasted hours for that month - again I am displaying week 1, 2, 3 etc as column.

    Here is my problem - I have created queries based on the month the hours occur. For months after June, because there is no data yet for the date or the number of hours worked my crosstab does not even display the week 1, 2, 3, 4 columns. I am also basing crosstab query 3 on crosstab query 2, if the week column does not show in crosstab 2 because of no date or hours data, my field select box for crosstab 3 does not show week 1, 2, 3 or 4 as fields to add to the query.

    Click image for larger version. 

Name:	6-20-2014 11-56-15 AM.jpg 
Views:	9 
Size:	6.4 KB 
ID:	16905

    'Aug Week 1' shows in this field selection box only because an employee has logged "future" hours for the time they know they will be on vacation.

    One solution I thought of was to add dates and zero values to table 1 however this is a data dump from the official DB the users enter their time to so I do not want to be manipulating that. I update it weekly.

    Is there any way (other than adding a bunch of bogus data to the source table) to force Access to display the columns? I have used the Nz function in fields before however if there is no data for the date in the source table there is no cell for me to apply the Nz to.

    Does any of this make sense?

    Thanks in advance for your help - If I am not clear (and I am sure it is confusing) let me know what info you would need to help me out!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    Basically, no. There must be records.

    If you had a master dataset of all possible username/project/week combinations, that dataset could be included and that would force at least one record for each. Then the columns would always generate but with empty cells if no data.
    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.

  3. #3
    RobertIngles is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    5
    Quote Originally Posted by June7 View Post
    Basically, no. There must be records.

    If you had a master dataset of all possible username/project/week combinations, that dataset could be included and that would force at least one record for each. Then the columns would always generate but with empty cells if no data.
    That's going to work I think - Needed to alter the joins to the date/week table (as it has every day in each month to define the weeks) and use the date/week table to be the basis of the columns.

    Thanks so much, I really appreciate it!!

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

Similar Threads

  1. Crosstab Column Sorting
    By Paul H in forum Queries
    Replies: 2
    Last Post: 09-12-2013, 03:21 PM
  2. Replies: 1
    Last Post: 02-03-2012, 05:39 PM
  3. Replies: 1
    Last Post: 12-08-2011, 08:03 AM
  4. Sums in First Column of Crosstab
    By JRINC in forum Queries
    Replies: 1
    Last Post: 10-06-2011, 02:47 PM
  5. Crosstab Column names used
    By JRINC in forum Queries
    Replies: 3
    Last Post: 09-29-2011, 02:46 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