Results 1 to 12 of 12
  1. #1
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83

    Calculating percent discount

    Hi All

    1. I have an order table that has a percent discount field that is populated from the Order form. Am I correct to assume that the calculation should take place in the Orders query?

    2. If I am correct in my assumption in the above point, where in the query do I run the calculation? I have already included the Discount field in he query, so do I do the calculation there? If so, what is the best coding to use?

    If I have missed the plot entirely will someone please put me on the right track?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    if the discount applies to the entire order then
    Q1 to sum all amt in the order
    Q2 to apply txtDiscount on the form and Q1.Total to create a SubTotal

  3. #3
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    I am assuming tha the "GroupBy" function pops up? hem which option do I use?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Group by is for the fields NOT to sum. (like clientID)
    SUM is for those you do.

  5. #5
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Please can you clarify where I must put the calculation and how you would suggest I should write it?

  6. #6
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    I used the following calculation in a calculated field in my query

    SalesPrice-(SalesPrice x (Discount/100))

    eg 300-(300 x (50/100)) = 150

    Do you agree?

  7. #7
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Query in design view

    Click image for larger version. 

Name:	query.jpg 
Views:	13 
Size:	70.8 KB 
ID:	31191

  8. #8
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    If that calculation is correct yes that seems a good place. you can rename it to DiscountPercent: or something instead of Expr1 and then use that as a field on the form. Assume SalesPrice is another field in the query?

  9. #9
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    why not just enter the discount rate as the decimal representation of the percentage (e.g. 25% is .25)? Makes it easier to write the expression regardless of which way you want to apply a rate. For example DiscAmt: [amt]-[amt]*[discount] No parentheses required either since the arithmetic operations will follow their natural course. The expression becomes 100-100*.25 = 75 To add 25%: 100*1.25 = 125

    Most of us would agree - do the calculation in the query or via calculated form controls. The former is usually better, IMHO. Rather than use the default alias of Expr1:, use your own meaningful field name, such as DiscAmt (discounted amount if that's the final figure you're creating).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You seem to be calculating the DiscountedPrice. But your post title is Calculating Percent Discount??

  11. #11
    Peter Simpson is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Location
    South Africa
    Posts
    83
    Oh hell...Orange...you are right. Thanks for all the help guys, I have managed to sort out the calculation and where to place it thanks to you guys....just one small issue remains......

    When I place it in the report I get the Label but the amount does not show...Why? What do I do?

    Click image for larger version. 

Name:	report.jpg 
Views:	13 
Size:	54.1 KB 
ID:	31193

  12. #12
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    In the property sheet for the report control, you have a table or query field set as its control source and that field is part of the query if it's based on a query?
    Or your report control calculated expression is using fields that are available to the report (i.e. are part of the report record source)?
    Or the record you're looking at does contain the required values?
    Or is this no longer a calculation of a discount amount but is instead a discount rate field from a table or query?
    Hard to know what your issue is now without more information about what you're doing at this point.

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

Similar Threads

  1. Calculating Percent in Report
    By pipoconanan45 in forum Reports
    Replies: 5
    Last Post: 09-08-2015, 10:47 PM
  2. Calculating Percent of a Test Score
    By cohnhead in forum Queries
    Replies: 5
    Last Post: 11-21-2014, 03:22 PM
  3. Replies: 2
    Last Post: 10-02-2013, 11:14 AM
  4. Calculate Discount
    By ryansox in forum Reports
    Replies: 2
    Last Post: 02-23-2013, 07:47 PM
  5. Yearly Discount Price By 20%
    By vdanelia in forum Forms
    Replies: 1
    Last Post: 02-04-2011, 10:27 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