Results 1 to 4 of 4
  1. #1
    farris is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    2

    Calculate discount out of combination customer ID and product ID

    I have made an invoice system in Access which works perfectly. I have the following tables:
    Customers, Invoices, Invoice Details, Products, Discounts
    the following queries:
    Invoice Details (combination of Invoice Details and Products tables) and Discountquery (just Discount table, does basically nothing actually right now).

    Now, I have a lot of forms where the most important one is the 'New Invoice' form (to enter the Invoice ID, Customer ID, Date, Invoice Notes) with a subform 'Subform Invoice Details' (to select the products). The source of the subform is the invoice details query. The field Invoice ID from the New Invoice form and the subform is connected so the right details are matched with the right invoice ID.

    However, I want some extra stuff in my program. When a customer is selected in the main form (New Invoice) and a product is added to the invoice(by the subform), I want a new field in my subform with 'Discount' that automatically connects the Customer ID (from the main form) and Product ID (from the same record in subform) to display the correct discount.

    But there's no idea how I can do that. I tried to add the table 'Discounts' to the query 'Invoice Details' with the criteria [Forms]![New Invoice]![Customer ID] but this results in a subform that doesn't work anymore. When I remove the table, it's working again.

    So, my question is, how can I achieve what I want? Is it possible with only the query 'Invoice Details' or do I need to make some seperate queries to come up with the right result?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I think you're going to want a field in the invoice details table, since the discount could presumably change over time. In the after update event of the product combo, use a recordset or DLookup() to find the appropriate discount and place it in that field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    farris is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    2
    Hmm, that's a nice suggestion..haven't thought of that. Will try to do so!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem; post back if you get stuck.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 12-24-2011, 08:48 AM
  2. Replies: 1
    Last Post: 03-22-2011, 07:01 PM
  3. Yearly Discount Price By 20%
    By vdanelia in forum Forms
    Replies: 1
    Last Post: 02-04-2011, 10:27 AM
  4. Replies: 3
    Last Post: 08-25-2010, 07:04 AM
  5. Replies: 1
    Last Post: 05-20-2009, 06:15 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