Results 1 to 7 of 7
  1. #1
    streub is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    42

    Price Calculation base upon product age

    I am new to this forum and to advanced Access 2013 features



    I have developed a database to catalog my clearance inventory and to determine how items should be priced based upon age.

    There are columns in the table for "date of arrival", "current date", "product age", "cost" and "discounted price".

    "Product age" is a calculated column subtracting "date of arrival" from "current date"

    The number of days determines what mark-up is applied.

    Example:

    0 to 30 days equals "cost" / 0.6
    31 to 60 days equals "cost" / 0.7
    61 to 90 days equals "cost" / 0.8
    91 to 120 days equals "cost" / 0.9

    I have attempted to use the expression builder using "IIF" but with not success. I have also attempted to use the macro builder but that has failed as well.

    Can someone give me some direction please?

    Thank you

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    And how was the calc not successful - error message, wrong results, nothing happens? Usually helpful to post your attempted code. If you tried a query then post the SQL statement. If you used an expression in textbox, provide that.

    However, maybe something like:

    Cost * Switch([ProductAge]<=30,0.6, [ProductAge]<=60,0.7, [ProductAge]<=90,0.8, True,0.9)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    First thing to note is that calculated fields are not stored in tables as they change. Use standard queries for these fields. What is the calculation to get number of days/age? There is a field "current date", what does that field contain?

    At a guess, Age = Date()-[tablename].[date of arrival]
    Then, Cost=IIf(Age<31,0.6,IIf(Age<61,0.7,IIf(Age<91,0.8, 0.9)))

  4. #4
    streub is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    42
    I did not consider using the because that is unknown territory. Both of you replied that is a step I should pursue.

    Where the calculation fails is in my expression structure. I can get close to what I need but when I try to use "and" with "between", I get a syntax error with or without "Eval".
    "Eval" is not recognized in the expression builder.

    The field "current date" contains "Now()".

    Are you both saying to dump the calc field(s) and use the form fields to perform the calculations?

    Both of you recommended a statement. Where would that be placed?

    Thank you

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Can use Calculated fields in table but they are less versatile. The IIf() is available but Switch() is not nor many other intrinsic functions. Many developers really don't like them and although I have never used, don't see anything wrong with them per se. However, if there is any possibility of migrating to another platform such as MySQL or SQLServer, they will be a headache, as will multi-value and attachment fields.

    Don't need BETWEEN and AND, as demonstrated in examples.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    streub is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    42
    I will keep you advised.

    Thank you

  7. #7
    streub is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    42
    This issue has been resolved using the recommendations. Thank you very much.

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

Similar Threads

  1. Last purchase price of a product sale
    By EMAS in forum Queries
    Replies: 4
    Last Post: 12-22-2015, 02:01 PM
  2. Replies: 17
    Last Post: 12-14-2015, 10:23 PM
  3. Replies: 6
    Last Post: 02-28-2015, 11:57 AM
  4. Replies: 4
    Last Post: 04-26-2013, 08:32 AM
  5. Replies: 1
    Last Post: 10-06-2009, 02:00 AM

Tags for this Thread

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