Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154

    Calculation

    Dear all

    I have a question on Access

    I have a data from Excel . see attached



    Date of tour and Tour type

    I have price for each Tour and promotional quote for each tour

    For example
    Tour 1 - price is $10
    Tour 2 -price is $20

    Promotion -
    C100 - less 10%
    B200 - less 20%
    E025 -less 25%

    I know i can use express builder to make the calculation of tour.
    but when i come to the promotion code, how can i address the C100 and total *0.1 , if B200 , then total * 0.2 ??

    Eric
    Attached Thumbnails Attached Thumbnails Test.JPG  

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    I'm not entirely clear on what your situation or what your database is like but it seems like you need a promo code lookup table. But It sounds like you're wanting to decode the promo code string to figure out the value?

    The excel table is confusing too. Does 12-oct show 3 different tours on the same day, or one tour that has 3 types?
    A promo code is good for just that day? That tour(s)?

  3. #3
    Join Date
    Apr 2017
    Posts
    1,792
    CHOOSE(MATCH(Promo,{"C100";"B200";"E025"},0),0.1,0 .2,0.025)
    I'm not sure about list delimiters here - maybe they must be commas for US settings? For me both delimiters for function parameters and list delimiters are semicolons.
    Replace Promo in formula with cell reference or with table column name - depending on type of formulas you use (table formulas or old type ones).

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

    Choose funtion

    Arvil


    I have made total:Nz([Tour 1])*20+Nz([Tour 2]*20)

    Then i made a discounted Price .... see attached

    the discounted price should be based on what in the [promo] ,


    I tried this in the "disccounted field" -Text31 :CHOOSE(MATCH([Promo],{"C100";"B200";"E025"},0),0.1,0 .2,0.025), it does not work

    Please kindly enlighten me further

    Thanks
    Attached Thumbnails Attached Thumbnails Eric.jpg  

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

    the user can take all "tours" in one day , i need to add all the cost together and less the discount from Promo

    See below

    Eric

  6. #6
    Join Date
    Apr 2017
    Posts
    1,792
    Quote Originally Posted by Erictsang View Post
    Arvil
    I tried this in the "disccounted field" -Text31 :CHOOSE(MATCH([Promo],{"C100";"B200";"E025"},0),0.1,0 .2,0.025), it does not work
    Sorry, I was just in excel forum before reading your post, and your datasheet (?) image was too worksheet like

    The simplest solution in access will be an UDF (i.e. your own function) IMHO.

  7. #7
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    i do not understand what you mean?!

  8. #8
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Dear all

    I have used the Switch function to solve the problem

    However, the result was calculate in an unbound field, how can i store it into the table?

  9. #9
    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 usually considered to be bad practice to save calculations, better to do the calculation whenever and wherever it is required
    See: http://allenbrowne.com/casu-14.html
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

    Dlookup

    I have a question again


    I made a table for the promotional code :

    Promo_code -Table


    [code] [dscount]

    C100 10%
    B200 15&

    Then , i made a Form - Master_F

    My idea is to calcuate the discounted rate,i.e total * discount % that represent by the promotion code.(refer to the above
    In this case, C100 ,10% discount, we expect 60*10% = 54

    =DLookUp([Promo_code]![Discount],[Promo_code]![Code],[Promo_code]![Code]=[Promo])*[Total]

    Can anyone be so kind to enlighten me

    Click image for larger version. 

Name:	discount_1.JPG 
Views:	16 
Size:	34.5 KB 
ID:	30091

  11. #11
    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
    The sytax to return the amount of discount from the table would be something like:
    =DLookUp("[Discount]","[Promo_code]","[Discount] = '" & Me.[Promo] & "'")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    Strange
    it prompts Error

  13. #13
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    thanks and with the following

    Click image for larger version. 

Name:	Dlookup-1.JPG 
Views:	16 
Size:	76.6 KB 
ID:	30093

    =DLookUp("[Discounted]","[Promo_code]","[Discount] = '" & Me.[Promo] & "'")

    I tried to take away the me. also error

    Eric

  14. #14
    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
    Can you post a copy of your db with a few dummy records to illustrate the problem
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    Erictsang is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    154
    I have solved it with the following

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

    I have a silly question, originally, i put down 10% as the discount rate in the Promo code 's discount
    However, when it comes to calculate [total]* 10%, it did not come out 54

    I have to change the discount to 0.9 , how can i solve it



    Click image for larger version. 

Name:	Dlookup_solved.JPG 
Views:	16 
Size:	67.4 KB 
ID:	30094

Page 1 of 3 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