Results 1 to 13 of 13
  1. #1
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314

    Cross-Tab Report?

    I would like to produce a report, which I believe would be a cross-tab report. See the sample Access Report and Excel Report.
    I would like to produce a report similar to the Excel report, from a report similar to the Access report.
    The cross-tab report would include the name and phone number (text deleted) from the member Table, and the Activity and Beg_Date, from the associated Assignments Table.



    Am I correct is calling this a cross-tab report? Can this be done? I have never produced a cross-tab report before, and am not sure how to do it. I didn't find the MS instruction very meaningful for me. See inline attachments.



    Click image for larger version. 

Name:	Sample Access Report.JPG 
Views:	22 
Size:	154.2 KB 
ID:	29934Click image for larger version. 

Name:	Sample CrossTab.JPG 
Views:	21 
Size:	223.1 KB 
ID:	29935

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    Not sure what you are asking. You want those fields you mentioned to be used in a Crosstab query/report which would look something like the excel report? If you want to try doing a crosstab query/report, create a query that contains your data fields(unless they are in same table), then use the Query Wizard(then select crosstab) on that query to see if you can get the output to be as you want.

  3. #3
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    OK. I have a query called, Trips by YearQ, which produces the data needed for the indicated Access report. It contains many more fields than needed for the cross-tab query/report, but it includes all those needed for the cross-tab. If I understand you correctly, I now create a cross-tab query that gets its data from "Trips by YearQ", selecting only the elements needed for the cross-tab query. Then I will use the cross-tab query as the data source for the cross-tab report?

  4. #4
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    I have the following cross-tab SQL

    TRANSFORM First([Trips by YearQ].[Activity]) AS FirstOfActivity
    SELECT [Trips by YearQ].[KeyName]
    FROM [Trips by YearQ]
    GROUP BY [Trips by YearQ].[KeyName]
    PIVOT Format([Beg_Date],"Short Date");

    [Trips by YearQ] query requests you to enter a year to produce the query for, and stores that into a variable called [This_Year]. The cross-tab query does not know how to deal with it. It reports, "Does not recognize '[This_Year]' as a valid name or expression". And I don't know how to get the cross-tab query to recognize it.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Not easy to do because of the dynamic nature of the column headers, especially when pivoting on date values.

    Filter parameters for CROSSTAB require special handling.

    Review http://allenbrowne.com/ser-67.html

    I don't think formatting to Short Date will get you want you want. Format function returns a string value which will not sort chronologically. To get the columns to order chronologically, either use the unaltered date value or format it like: Format([Beg_Date], "mm/dd") so the output will be like 08/10, 11/29, etc. and the alpha sorting will appear as chronological.
    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. #6
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Great. Thank you June7. I set a parameter to [This_Year] as short text. It allowed the query to go and it works. Some of the events are not sorted correctly, as you said they would not. Any suggestion on how can I see just the date and exclude the time in the pivot columns and still get them to sort?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    I suggested a Format expression.
    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.

  8. #8
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Sorry. That was dumb. After going to the link, I forgot to finish reading your response.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    And if you want to show month name along with month number, consider: Format(Date(),"mm(mmm)/dd"). If you prefer, use a - in place of /.
    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.

  10. #10
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Thanks. Now I need to figure out how to create a dynamic report based on this query. Reading MS's how to, sounds quite complicated.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Yes, it is. There is a link to an example in Allen Browne's article.
    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.

  12. #12
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Has anyone written a generic VBA code to work with any cross tab query, by just supplying the name of the query to process? This cross tab query produces a variable number of columns and column headings.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Variable number of columns and changing header names in a CROSSTAB is to be expected because they are derived from data and data changes, especially when pivoting on date values. The Allen Browne link is best reference I know of for examples of handling dynamic CROSSTAB in a report and I suppose even it won't deal with every situation. Yours may be one.

    I have resorted to 'temp' table and VBA for process that required rearranging data horizontally. https://forums.aspfree.com/microsoft...ry-322123.html
    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.

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

Similar Threads

  1. Pass Parameters from Cross Tab Query to Report
    By jokeboy1 in forum Reports
    Replies: 5
    Last Post: 01-02-2015, 01:26 PM
  2. Summing a Cross Tab in Report Footer
    By Tammy in forum Reports
    Replies: 1
    Last Post: 11-28-2014, 02:08 AM
  3. Cross tab report
    By wnicole in forum Reports
    Replies: 2
    Last Post: 10-09-2013, 05:07 AM
  4. Report is cross printing
    By wildthingcg in forum Reports
    Replies: 6
    Last Post: 01-04-2013, 10:30 AM
  5. Adding rows on cross-tab query report
    By KahluaFawn in forum Reports
    Replies: 2
    Last Post: 02-18-2009, 10:09 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