Results 1 to 6 of 6
  1. #1
    bootu is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    7

    Query for selecting a price change in sales table for the past year

    I have a table with product ID, Price, and invoice date. I am trying to write a query that will return one or more lines where it ONLY shows the NEW AND OLD PRICE AND WHEN(invoice date) the price has changed in the past year!



    Any help is appreciated.

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    make a form with text boxes to hold the date range, form: frmRpt
    txtStartDate, txtEndDate, txtBoxRng

    make a query with product ID, Price, and DateRange, qsThisYearData
    DateRange = "Jan2016-Dec2016" to show the year range. (you cant use Invoice date, but it IS in the where clause of the query)

    select distinct product ID, Price, forms!frmRpt!txtBoxRng as DateRange where [invoice date] between forms!frmRpt!txtSTartDate and forms!frmRpt!txtEndDate

    and another query to show the items a year ago
    select distinct product ID, Price, "PrevYr" as DateRange where [invoice date] between dateadd("yyyy",-1,forms!frmRpt!txtSTartDate) and dateadd("yyyy",-1,forms!frmRpt!txtEndDate)

    now join the 2 queries and show the 2 different years side by side, filter out the ones that equal.

  3. #3
    bootu is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    7
    I appreciate the quick reply. I forgot to mention that users will be required to enter the product id and start and end date! Thanks

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    then a combo box for the PROD ID, and add the box to the query.

  5. #5
    bootu is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    7
    Thank you! I will give a shot and post my results. I appreciate the prompt response.

  6. #6
    bootu is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    7
    I have one last question. Instead of users entering one Product_ID at a time, how do I create a form that users can click on as empty table so users can paste numerous product_id's and still do what I originally want to do. Thanks

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

Similar Threads

  1. Replies: 17
    Last Post: 12-14-2015, 10:23 PM
  2. Replies: 2
    Last Post: 04-25-2014, 11:33 PM
  3. Replies: 2
    Last Post: 12-27-2013, 05:20 PM
  4. Replies: 5
    Last Post: 12-26-2013, 06:12 AM
  5. Variation of past and current sales
    By v!ctor in forum Access
    Replies: 2
    Last Post: 03-16-2013, 09:06 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