Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614

    Maybe:

    Round((100-DLookUp("[Discount]","[Promo_code]","[code]= '" & [Promo] & "'"))*[Total])
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  2. #17
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Bob

    With your formular, i get wrong calculation

    If the [total] is 60 and the discount rate is 5%

    it should be (1-5%)* 60=57


    Discounted Fee: Round(100-(DLookUp("[Discount]","[Promo_code]","[code]= '" & [Promo] & "'"))*[Total]) but the outcome is 97


    Any idea why?
    Eric

  3. #18
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I don't understand why you have used Round(). I have tested following Calculation which works for me.

    Discounted Fee:((100-DLookUp("[Discount]","[Promo_code]","[code]= '" & [Promo] & "'"))*[Total])/100
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #19
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Sorry, my mistake. I understand now why you have used Round() so calculation should be:

    Discounted Fee:Round(((100-DLookUp("[Discount]","[Promo_code]","[code]= '" & [Promo] & "'"))*[Total])/100,2)
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #20
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Bob

    I have made the following to solve the problem but when i come to round up, it wrong again.

    Discount : Round(1-DLookUp("[Discount]","[Promo_code]","[code]= '" & [Promo] & "'")*[Total],1)

    the syntaxof round should be

    Round (expression, decimal)




    Click image for larger version. 

Name:	round.JPG 
Views:	15 
Size:	38.6 KB 
ID:	30097

  6. #21
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Have you tried the expression I gave in post #19
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #22
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Thanks, i applied your expression but the result is wrong
    B100 , is 5%, so for $60-5% , that is 57



    Something wrong





    Click image for larger version. 

Name:	Round_2.JPG 
Views:	15 
Size:	42.9 KB 
ID:	30098

  8. #23
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    By the way, how i can upload the access file on this forum?!

  9. #24
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by Erictsang View Post
    By the way, how i can upload the access file on this forum?!
    To provide db: Make copy, remove confidential data, run compact & repair, zip w/Windows Compression if over 500KB (2MB zip allowed), attach to post. Attachment Manager is below the Advanced post editor window, click Go Advanced below the Quick Reply window.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #25
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Bob

    it is not working


    I have saved the file in Dropbox, appreciate if you can take a look

    Million thanks


    https://www.dropbox.com/s/9zhh6a9sw5...se6.accdb?dl=0

    Click image for larger version. 

Name:	dlookup_1.JPG 
Views:	12 
Size:	45.2 KB 
ID:	30101Click image for larger version. 

Name:	dlookup_2.JPG 
Views:	12 
Size:	39.9 KB 
ID:	30102

  11. #26
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Take a look at the attached file
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #27
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Bob

    Thanks and it is solved

    But how can i save the result into the master record ?

  13. #28
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    It is not usually considered to be good practice to save calculations, rather do the calculation whenever and wherever it is needed. See: http://allenbrowne.com/casu-14.html

    That said, if this were one of those times when it was considered to be better to save the calculated results to a table you could do it with code in the forms AfterUpdate event as shown in the attached file:
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #29
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    BOB

    Thanks so much for your help

    I have another issue on the Requery.

    I have no idea why i place the me.requery at the Choice form. Which trigger the choice query and displayed in the Choice subform.

    it does not be able to refresh, i have to click refresh everytime.

    Do you mind to have a look for me

    https://www.dropbox.com/s/cb2sgihf6a...est.accdb?dl=0

    Thanks thanks and thanks

    Eric

  15. #30
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I wouldn't use a query to present data to the user. Better to use a report or a form. Perhaps the attached db would suffice.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Age Calculation
    By muncher in forum Access
    Replies: 3
    Last Post: 05-20-2015, 03:52 PM
  2. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  3. Calculation
    By magootrp4 in forum Programming
    Replies: 1
    Last Post: 03-12-2012, 12:38 PM
  4. Calculation
    By buienxg in forum Access
    Replies: 1
    Last Post: 11-16-2011, 07:20 AM
  5. Calculation value not less than 1
    By vbpeterson in forum Queries
    Replies: 10
    Last Post: 08-17-2011, 06:41 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