Creating Microsoft Access Monthly Summary Crosstab Query Reports without Programming Codeby Luke Chung, President of FMS, Inc. Introduction. A well designed database stores data in a normalized format with dates defined in a field so that new data is simply added as additional records. However, people want to see data with dates grouped by columns. How can we do this for any 1. This paper shows an easy way to display monthly summaries for any 1. A sample database is included to show how this is done Download 1. Example Of Microsoft Access Report Sum' title='Example Of Microsoft Access Report Sum' />Demonstrates two methods that you can use to create a running totals query in Microsoft Access. Microsoft Access report tutorial Access database report examples design, programming and customization techniques with MS Access Visual Basic code samples with. KOur Objective Report with Monthly Columns. Heres an example using the Orders data from the old Northwind database showing monthly sales by country. Each country is a separate row, each. Example of a 1. 2 month Report for Any Date Range sorry for the data from the 1. Microsoft table. The user can specify the starting month of the report and automatically show 1. The column titles show the year and month. If. there is no data for a particular month, the report still shows the column with no data under it. Challenges. Data Storage is Different from the Way It Needs to be Displayed. Databases store data optimally in normalized, tabular manner. One sign of a good database design is that as time passes, new fields never. New dates, clients, contacts, etc. However, data often needs to be displayed in a spreadsheet or matrix format with different values in the columns. Naturally, these columns change over time. Crosstab Queries. Fortunately, Access crosstab queries make it easy to transform and summarize data from rows to columns. A crosstab lets you. However, the columns of a crosstab query change based on the data in the selected column field and can change over time. Free Wifi Software For Windows 7 Ultimate. Additionally, if. This creates problems if a. Introduction to Crosstab Queries. Heres a quick introduction to crosstab queries. For more information, see the online Access help for. Crosstab is one of the Microsoft Access Query Types Crosstab is a Microsoft Access Query Type. Unlike other query types, the Query Designer for Crosstabs has an extra Crosstab row to specify each of. Columns can be a field or expression. This example shows a crosstab grouped by Country. Order. Date, and displaying total sales Design view of Crosstab query qry. Country. Monthly. Sales. XTABWhen you run the query, the summarized sales displayed for each month as a separate column some columns not displayed here Crosstab Query with Actual Month Year as Columns. Creating Crosstabs with Fixed Column Names. Microsoft Access reports reference field names directly. If we want. to use a crosstab query as the Record. Source of a report, its column names. Fortunately, theres an easy way to make sure our crosstab query. Take a look at the query qry. Country. Monthly. Sales. Date. XTAB with Start. Date. parameter in the criteria. This prompts the user for the date of the. Query design of qry. Country. Monthly. Sales. Date. XTABUse Numbers Rather than Specific Month Names. In the original crosstab query qry. Country. Monthly. Sales. XTAB, each month. That makes it difficult for a report. A better approach is to define each month as a number between 1 and. This is defined in the ad. Country. Monthly. Sales. Date. XTAB. The trick is to think of each month as a unique number starting from. YearOrder. Date1. FormatOrder. Date,mm. YearStart. Date. FormatStart. Date,mm 1. The equation defines each month as a number Years 1. Month and. subtracts the Start. Date month from the Order. Date month plus one. The. result is a month number from 1 to 1. The result is this Use the PIVOT IN Clause to Specify Required Column Names. Defining the month number is the first step and works great if you. However, if a month doesnt have any. We want to ensure every. This is accomplished by using the IN clause in the crosstab syntax. To do this, we need to edit the SQL string of the query and insert the. IN clause. Heres the query PARAMETERS Start. Date Date. Time TRANSFORM SumUnit. PriceQuantity1 Discount1. AS. Sales. SELECT Orders. Ship. Country FROM Orders INNER JOIN Order Details ON Orders. Order. ID Order. Details. Order. ID WHERE Orders. Order. Date Start. Date GROUP BY Orders. Ship. Country. PIVOT YearOrder. Date. 2FormatOrder. Date,mm YearStart. Date. 2FormatStart. Date,mm1. 1,2,3,4,5,6,7,8,9,1. The important part is the last line highlighted in red. By adding the. IN clause and listing the column names required, the crosstab always. The IN clause also limits columns e. Report Design. With the crosstab defining each month as a set number, we simply. Report design of rpt. Sales. By. Month. Column Names. To label each column, we translate the month column based on the Start. Date. parameter with the Format property set to yyyy mm. For instance Column 1 is Start. DateColumn 2 is Date. Addm,1,Start. DateColumn 3 is Date. Addm,2,Start. Dateetc. Column 1. Date. Addm,1. Start. DateThe VBA Date. Add function when passed the m parameter adds the. Start. Date to create the new date that the. Format property is applied for display. Preview the Report. The. result is a nicely formatted monthly summary report that adjusts to any starting month a user enters. The sample data is from Northwind which has Order. Date between July. May 1. 99. 8. Preview the report and enter the Start. Date Youll see the report shown at the beginning of this paper. Automatically Handles Missing Months. If you enter 119. Start. Date, youll see the report also works. This is because of the. IN clause in the crosstab Example of missing data as blank columns. If you want to show the column headings with Year Month e. Jan, then use the date format as yyyy mmm to show the month. Additional Resources. Here are other related resources for data analysis and crosstabs Conclusion. The need for monthly summary reports is quite common. Hopefully, the techniques shown here will help you create richer Access reports and use. Good luck About the Author. Luke Chung is the President and Founder of FMS, Inc., the worlds leading provider of Microsoft Access. Visit the FMS web site for additional Access resources, utilities, technical papers. People Microsoft Research.