# Price Calculation base upon product age

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. 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)

3. Competent At Times
Windows 10 Access 2013 64bit
Join Date
Nov 2011
Location
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)))

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. 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.

Windows 10 Access 2013 64bit
Join Date
Oct 2017
Posts
42

Thank you

Windows 10 Access 2013 64bit
Join Date
Oct 2017
Posts
42
This issue has been resolved using the recommendations. Thank you very much.