473,507 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Report to Compare Sales in This and Previous Year

79 New Member
I am working on a sales report that needs to compare sales (in dollars and in cases sold) grouped by Customer and by Month. The report format is as attached image (created by MS Word for demonstration).

The report opened with criteria using invoice date specified on two text boxes (txtFromDate and txtToDate) from form “F_Sales_Date”. Another two hidden text boxes “txtFromDate2” and “txtToDate2” are calculated same date period for previous year.

Learning from an example, my approach to this task is to create two separate queries then join the two queries with Customer No field "ordh_cust_no". The results of join query looked fine. I can see all information I needed and can easily manipulate the data in a spreadsheet. However, I cannot put them in Access report with the format I wanted.

The involved tables are listed below.

Relevant fields from Table "DBA_order_header"
Expand|Select|Wrap|Line Numbers
  1. ordh_cust_no
  2. ordh_last_inv_no
  3. ordh_time_inv_printed
  4. ordh_ord_no
  5.  
Relevant fields from Table "DBA_order_detail"
Expand|Select|Wrap|Line Numbers
  1. ordd_stock_no
  2. ordd_qty_ordered
  3. ordd_ord_no
  4.  
Relevant fields from Table "DBA_customers"
Expand|Select|Wrap|Line Numbers
  1. cust_lname
  2. cust_no
  3.  
Relevant fields from Table "DBA_inv_payment"
Expand|Select|Wrap|Line Numbers
  1. pymt_invoice_amt
  2. pymt_ord_no
  3.  
Relevant fields from Table "DBA_inventory"
Expand|Select|Wrap|Line Numbers
  1. stock_desc
  2.  
Two involved queries are listed below.

Query 1: Q_Sales_Report_2Yrs1
Expand|Select|Wrap|Line Numbers
  1. SELECT DBA_order_header.ordh_cust_no, DBA_customers.cust_lname, DBA_order_header.ordh_last_inv_no, DBA_order_header.ordh_time_inv_printed, DBA_inv_payment.pymt_invoice_amt, DBA_order_detail.ordd_stock_no, DBA_inventory.stock_desc, DBA_order_detail.ordd_qty_ordered
  2. FROM (((DBA_customers INNER JOIN DBA_order_header ON DBA_customers.cust_no = DBA_order_header.ordh_cust_no) INNER JOIN DBA_inv_payment ON DBA_order_header.ordh_ord_no = DBA_inv_payment.pymt_ord_no) INNER JOIN DBA_order_detail ON DBA_order_header.ordh_ord_no = DBA_order_detail.ordd_ord_no) INNER JOIN DBA_inventory ON DBA_order_detail.ordd_stock_no = DBA_inventory.stock_no
  3. WHERE (((DBA_order_header.ordh_time_inv_printed)>=[Forms]![F_Sales_Date]![txtFromDate] And (DBA_order_header.ordh_time_inv_printed)<=[Forms]![F_Sales_Date]![txtToDate]));
  4.  
Query 2: Q_Sales_Report_2Yrs2
Expand|Select|Wrap|Line Numbers
  1. SELECT DBA_order_header.ordh_cust_no, DBA_customers.cust_lname, DBA_order_header.ordh_last_inv_no, DBA_order_header.ordh_time_inv_printed, DBA_inv_payment.pymt_invoice_amt, DBA_order_detail.ordd_stock_no, DBA_inventory.stock_desc, DBA_order_detail.ordd_qty_ordered
  2. FROM DBA_inventory INNER JOIN (((DBA_customers INNER JOIN DBA_order_header ON DBA_customers.cust_no = DBA_order_header.ordh_cust_no) INNER JOIN DBA_inv_payment ON DBA_order_header.ordh_ord_no = DBA_inv_payment.pymt_ord_no) INNER JOIN DBA_order_detail ON DBA_order_header.ordh_ord_no = DBA_order_detail.ordd_ord_no) ON DBA_inventory.stock_no = DBA_order_detail.ordd_stock_no
  3. WHERE (((DBA_order_header.ordh_time_inv_printed)>=[Forms]![F_Sales_Date]![txtFromDate2] And (DBA_order_header.ordh_time_inv_printed)<=[Forms]![F_Sales_Date]![txtToDate2]));
  4.  
These two queries are essentially the same except the invoice date (ordh_time_inv_printed) from each query pointed to the period of this and previous year respectively as mentioned above using criteria listed below.

Criteria of invoice date (ordh_time_inv_printed) in Query “Q_Sales_Report_2Yrs1”:
Expand|Select|Wrap|Line Numbers
  1. >=[Forms]![F_Sales_Date]![txtFromDate] And <=[Forms]![F_Sales_Date]![txtToDate]
  2.  
Criteria of invoice date (ordh_time_inv_printed) in Query "Q_Sales_Report_2Yrs2":
Expand|Select|Wrap|Line Numbers
  1. Criteria of field “ordh_time_inv_printed”:   >=[Forms]![F_Sales_Date]![txtFromDate2] And <=[Forms]![F_Sales_Date]![txtToDate2]
  2.  
The joined query "Q_Sales_Report_Comp_Cust":
Expand|Select|Wrap|Line Numbers
  1. SELECT Q_Sales_Report_2Yrs1.ordh_cust_no, Q_Sales_Report_2Yrs1.cust_lname, Q_Sales_Report_2Yrs1.ordh_last_inv_no, Q_Sales_Report_2Yrs1.ordh_time_inv_printed, Q_Sales_Report_2Yrs1.pymt_invoice_amt, Q_Sales_Report_2Yrs2.ordh_cust_no, Q_Sales_Report_2Yrs2.cust_lname, Q_Sales_Report_2Yrs2.ordh_last_inv_no, Q_Sales_Report_2Yrs2.ordh_time_inv_printed, Q_Sales_Report_2Yrs2.pymt_invoice_amt, Q_Sales_Report_2Yrs1.ordd_stock_no, Q_Sales_Report_2Yrs1.stock_desc, Q_Sales_Report_2Yrs2.ordd_stock_no, Q_Sales_Report_2Yrs2.stock_desc, Q_Sales_Report_2Yrs1.ordd_qty_ordered, Q_Sales_Report_2Yrs2.ordd_qty_ordered
  2. FROM Q_Sales_Report_2Yrs1 INNER JOIN Q_Sales_Report_2Yrs2 ON Q_Sales_Report_2Yrs1.ordh_cust_no = Q_Sales_Report_2Yrs2.ordh_cust_no
  3. ORDER BY Month([Q_Sales_Report_2Yrs1].[ordh_time_inv_printed]), Month([Q_Sales_Report_2Yrs2].[ordh_time_inv_printed]);
  4.  

As for the report, my problem is grouping based on month. When I grouped month from each query, one following the other one, the result is that all monthly sales of 2nd year listed under each month of 1st year and repeated every month from 1st year.

In addition, I cannot figure out the way to arrange items sold in each month the way I wanted in format as shown in attachment. If nothing sold of an item in certain month I still want the item listed with Invoice as $0 and case as 0.

Can someone help me with this report design? Is it query design that needs to be worked on or report design that can solve the problem?

Thanks in advance!

Attached Images
File Type: jpg Sales Rpt.jpg (78.0 KB, 1469 views)
Attached Files
File Type: docx Example Report.docx (19.7 KB, 315 views)
Jun 24 '15 #1
1 5006
zmbd
5,501 Recognized Expert Moderator Expert
if the query is returning the correct data then we're looking at the report formatting and there are some limitations to the Access reporting.

I am unfortunately not in a position to open your attachment. If it has an image, please pull that image out and attach it directly using the advanced editor.

The months without data is a secondary question and may be solvable using an expansion query or conditional.
Jun 27 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
23847
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
1
4046
by: Terencetrent | last post by:
I have created a query that examines qarterly sales for 5 regions in the country. The query contains data for the past 6 quarters for each region and calculates the perecentage of total sales for...
3
5852
by: Bob | last post by:
I wish to group data on a report by week, month and year. Crystal reports has this ability as a built in function. Is there a quick way to do this in Access97/2000 VBA reports ? Thank you in...
2
3552
by: Bernd Hohmann | last post by:
Dear collegues, small query problem. A table (simplified example)... customer as char(5) inv_date as date amount as double
3
16503
by: jannoergaard | last post by:
Hi I want to write a function that can return a sum for a given date range. The same function should be able to return the sum for the same period year before. Let me give an example: The...
4
10514
jiffylube
by: jiffylube | last post by:
I'm putting together a retail comp report that compares the current day stats to the same day, previous year. Is there a code I can use to get last year, same day? For example: This year stats=...
1
4604
by: craigfr | last post by:
I want to create a graph (automatically in a report) which compares the current year's values to the previous years by plotting two lines on one chart. I have one table which has the fields: ...
7
6190
by: beaudreaux | last post by:
I am needing to calculate a month to date for the previous year in a report. Example: today is 02/18/10 and I have a month to date for today(current year). I need the report to also show month to...
1
5471
by: popovaa | last post by:
Hi: i need to get data for a time frame in a current year and same time frame in previous year. i found the below on this site which is almost what i need but i also need help on how to adjust the...
2
3453
by: fredmart | last post by:
Hi, I'm having problems finding a way to apply conditional formatting based on comparing the text contents of two fields in two different tables. What I'd like to do: I've got two tables that...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.