Results 1 to 5 of 5
  1. #1
    venus is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    3

    Crosstab Query to include all records from two tables/querys to count no of records.


    Hai fiends. i have three tables
    1)TaskType tbl with fields TaskTypeID(PK), TaskType
    2) Places tbl with fields PlaceID(PK), Place
    3)Task tbl with fields TaskNo(PK), TaskTypeID(FK), placeID(FK), Task etc.

    I want to create a crosstab query to count all records in table3, TaskType as column heading and Place as row heading, query should display all records from TaskType and place tbls. count should show as 0 if no task is done at place and TaskType.


    Help me pls.

    Thank you in advance.

  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,913
    If I understand your requirements, I think you need a dataset of all possible TaskType and Place pairs. This can be generated with a query that includes both TaskTypes and Places tables but without a join clause. This will be a Cartesian relation where every record in each table will join with every record in other table.

    Then use that query in another query that joins with the Task table, join type "Include all records from {first query} and only those from Task that match". Do a compound join on the TaskTypeID and PlaceID fields.

    Then use that second query as the source for a CROSSTAB.
    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
    venus is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    3
    Thank you its working.But, crosstab query showing first row all zeros and first column heading blank. How can i remove this first row.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Maybe apply a filter that excludes all records where that field Is Null?
    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.

  5. #5
    venus is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2014
    Posts
    3
    Thank you again.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-30-2013, 01:49 PM
  2. Count records from multiple tables
    By jazzin in forum Queries
    Replies: 1
    Last Post: 07-24-2013, 08:16 AM
  3. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  4. Include ROW Count in Query???
    By taimysho0 in forum Queries
    Replies: 21
    Last Post: 05-25-2012, 05:29 PM
  5. Replies: 3
    Last Post: 01-05-2012, 12:04 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