473,659 Members | 2,632 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_head er"
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_deta il"
Expand|Select|Wrap|Line Numbers
  1. ordd_stock_no
  2. ordd_qty_ordered
  3. ordd_ord_no
  4.  
Relevant fields from Table "DBA_custom ers"
Expand|Select|Wrap|Line Numbers
  1. cust_lname
  2. cust_no
  3.  
Relevant fields from Table "DBA_inv_paymen t"
Expand|Select|Wrap|Line Numbers
  1. pymt_invoice_amt
  2. pymt_ord_no
  3.  
Relevant fields from Table "DBA_invent ory"
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, 1473 views)
Attached Files
File Type: docx Example Report.docx (19.7 KB, 316 views)
Jun 24 '15 #1
1 5034
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
23870
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 to use a database table but all I want to do now is to click a command button to display this access report. Any suggestions please ?????
1
4052
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 the quarter fo each region. To help enhance the report I would love to include a comparison to of current sales to previous quarter sales and a comparison of current sales to sales a year ago. I am having a devil of a time creating a query to...
3
5864
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 advance, Bob.
2
3560
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
16510
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 Table LedgerTrans consist among other of the follwing fields AccountNum (Varchar) Transdate AmountMST (Real)
4
10526
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= 7/22/2007-Sunday Previous year= 7/23/2006-Sunday I need to be able to put this string into the design view in a criteria field. For Calendar comp I use the following. This year:...
1
4613
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: Date and DeckDefects (which is a number) I would like the X axis to show months and the Y axis to show # of DeckDefects
7
6207
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 date for 02/18/09. I believe I would be able to manipulate my current formula that figures the month to date for the current year, but I have been unsuccessful so far. I have the current year, month to date formula of: =DAvg("","","Date Between #" &...
1
5495
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 code if a have parameters @Start_Date and @End_Date (these are obviously the beginning and the end of the time frame). Also, i would like the date to be entered in MM/DD/YYYY format and not the YYYYMMDD. This is somewhat urgent request. If someone...
2
3477
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 are identically structured with about 50 fields each. The two tables are used for two data inputters to independently enter the same data from the same source as part of a validation check. I want to be able to check which if any fields are...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.