Results 1 to 14 of 14
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Calculating Percentage

    Adding discount percentage to a price



    Hi Guy's i have got this working but the wrong way round, what's the quick fix to this one please ?

    When I choose 40 in the txtDisc box, its lees than half, if I choose 60 in the txtDisc, it's more than half

    It should be the other way around!

    Code:
    Dim OrgVal As Currency, myDisc As Double, NewVal As Currency
    
    OrgVal = Me.txtNett
    myDisc = "0." & Me.txtDisc
    
    
    NewVal = OrgVal * myDisc
    Me.txtNett = NewVal
    Me.txtVat = Me.txtNett * 0.2
    Me.txtTotal = Me.txtNett * 1.2

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    You subtract your discount?
    So calculate and subtract it from the original amount?

    I was not even aware you could do math with strings?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi WGM so in the txtDisc text box, i have 40 then on my calculation 100 becomes 60 then if i have 60, 100 becomes 40

    I must need to change the method around ? and which part would i change ?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Quote Originally Posted by DMT Dave View Post
    Hi WGM so in the txtDisc text box, i have 40 then on my calculation 100 becomes 60 then if i have 60, 100 becomes 40

    I must need to change the method around ? and which part would i change ?
    If you have £100 and you offer 40% discount, then the remaining value will be £60? the same if you offer 60% discount?

    To keep things simple.....

    NewVal = OrgVal - (OrgVal * Val(MyDisc))
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Is this what your after?

    Code:
    Dim OrgVal As Currency, myDisc As Double, NewVal As Currency
    
    OrgVal = Me.txtNett
    myDisc = Me.txtDisc/100.0
    
    
    NewVal = OrgVal * (1-myDisc)
    Me.txtNett = NewVal
    Me.txtVat = Me.txtNett * 0.2
    Me.txtTotal = Me.txtNett + Me.txtVat

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I can't make any sense out of that. If you start with 100
    NewVal = 100 * .4 = 40
    Me.txtNett = 40
    Me.txtVat = 40 * 0.2 = 8
    Me.txtTotal = 40 * 1.2* 1.2 = 57.6
    Yet you say
    When I choose 40 in the txtDisc box, its lees than half,
    without saying what "it" is - the discounted amount or the discount itself. 40 is certainly less than half the amount you started with but it's also less than half discount (50% discount).

    Posting actual numbers and expected results is always a good idea. I wouldn't prepend text to numbers as it will convert your number to text, which Access will interpret as a number when it can. However, you get away with it only because you're not trying to do this to one of your variables. So either users need to enter .40 or you multiply their integer only input of 40 first: 40*.01 (or divide 40/100).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    OP is not applying the discount, but making the new value the discount?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by Welshgasman View Post
    OP is not applying the discount, but making the new value the discount?
    Must be, or is arriving at the value but wants the discount amount (value of the discount) too, because this makes perfect sense to me
    i have 40 then on my calculation 100 becomes 60 then if i have 60, 100 becomes 40
    100 discounted 40% = 60
    100 discounted 60% = 40
    Last edited by Micron; 09-11-2021 at 09:37 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Sorry Micron, what I was trying to say that instead of applying the discount, the OP was making the new value the discount.
    Hence the incorrect value for what the OP wanted.

    Emphasis purely for the OP.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    thank you to all of you guys, will make the adjustments...

  11. #11
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    thank you for this, the formula that kd2017 suggested works great and read all other comments to assess options

    thank you again

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Quote Originally Posted by DMT Dave View Post
    thank you for this, the formula that kd2017 suggested works great and read all other comments to assess options

    thank you again
    All well and good, but whilst it works (as mine should? ), do you understand it?

    That is why I used the Orig value twice, so you could see exactly what you are meant to do.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi WGM, yes thank you, i have played around with all suggestions and figured out all suggestions posted

    Thank you, stuck another post coming up now

  14. #14
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Adding a link reply to email body

    Hi Guy's after a little research, i am loosing myself here!!! can someone correct the html code for me please and point out where i am going wrong so that I can understand your changes

    I HOPE ALL OF THIS MAKES SENSE!!!

    I am looking to add 2 choices of links to an email where the recipient can click the relevant option and that would send back to us

    The email we would receive from that link if Opt1 was clicked is:

    "Thank you very much, I can confirm that I received my " & "£" & Me.Value & " along with my free gift"

    The email we would receive from that link if Opt2 was clicked is:

    "Thank you, the engineer that arrived did make an adjustment to the arrangements that we agreed with yourselves."
    "Please inform us of the adjustments that the engineer made with you ?"

    Note I haven't put all Dim's in but all Dim's are set as Strings apart from Calling Email

    Outgoing mail body is "a" to "j"

    Linked Reply options are Opt1 and Opt2

    Reply Body is Return1, Return2, Return3

    Code:
    a = TOD & " " & myClient        b = "Thank you for using our services recently to remove your redundant product."
            c = "It is very important to us as we pride ourselves in serving all clients with a great service, we are just wanting to check to make sure that the full procedure was carried out according to plan."
            d = "1: Did you receive your payment of £" & Me.Value & " ?"
            e = "2: Did you receive your free gift ?"
            f = "To prevent having to write out another email, simply click on the relevant link below to confirm all arrangements such as payment received ok and you were rewarded with your free gift."
            g = "Finally, we just want to say thank you again for using our services and it was an absolute pleasure to assist, please stay safe."
            h = "With Our Kindest Regards"
            j = myName
            Return1 = "Thank you very much, I can confirm that I received my " & "£" & Me.Value & " along with my free gift"
            Return2 = "Thank you, the engineer that arrived did make an adjustment to the arrangements that we agreed with yourselves."
            Return3 = "Please inform us of the adjustments that the engineer made with you ?"
            mySubj = "Courtesy Email Ref " & Me.RecordNo
            Opt1 = "Click here to confirm all was received as agreed"
            Opt2 = "Click here to confirm that the engineer had to adjust the agreements made"
                Set oEmailItem = oOutlook.CreateItem(olMailItem)
                With oEmailItem
                    Set OutAccount = oEmailItem.Session.Accounts.Item(2)
                    .To = myEmail
                    .HTMLBody = a & "<br>" & "<br>" & b & "<br>" & "<br>" & c & "<br>" & "<br> " & _
                    d & "<br>" & e & "<br>" & "<br>" & f & "<br>" & "<br>" & g & "<br>" & "<br>" & h & "<br>" & "<br>" & _
                    i & "<br>" & "<br>" & d & "<br>" & j & "<br>" & "<br>" & _
                    opt1 & "<a href=mailto:removedonhere.com?subject=" & mysubj & body=" & return1 & "<br>" & "<br>" & _
                    opt2 & "<a href=mailto:removedonhere.com?subject=" & mysubj & body=" & return2 & "<br>" & "<br>" return3 & "<br>" & "<br>" & _
                    "<P><IMG border=0 hspace=0 alt='' src='file://T:/Email Signature.jpg' align=baseline></P>" & "<br>" & "<br>" & _
                    "<FONT color=#0000CD>" & eDisc & "<br>" & "<FONT color =#0000CD>" & eDisc2
                    .SendUsingAccount = OutAccount
                    .Display
                End With
    Click image for larger version. 

Name:	Email Link.jpg 
Views:	9 
Size:	90.7 KB 
ID:	46222

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

Similar Threads

  1. Replies: 6
    Last Post: 07-18-2020, 01:03 PM
  2. Percentage
    By azhar2006 in forum Queries
    Replies: 3
    Last Post: 11-15-2014, 02:22 PM
  3. Calculating Percentage
    By robsworld78 in forum Forms
    Replies: 17
    Last Post: 07-03-2011, 06:30 PM
  4. Calculating a Percentage
    By Alaska1 in forum Access
    Replies: 7
    Last Post: 12-13-2010, 05:57 PM
  5. Replies: 3
    Last Post: 12-01-2010, 12:30 PM

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