expression value in table to return FY

pastorkc

Board Regular
Joined
Jan 29, 2020
Messages
125
Office Version
  1. 2010
Platform
  1. Windows
I have this expression in my Default Value area of my table for field FY. It just errors out. I would like it to look at the Date field and if the month is less than 7 then put in the year, if it is greater than 7 then add 1 to the year.

=IIf(Month("«date»")<7,Year("«date»"),Year("«date»")+1)
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Your formula should be "=IF" not "IIF"

see test sheet below; it has 2 ways of implementing your formula:
GetLastRow.xlsm
AB
397/19/20232024
402024
Sheet3
Cell Formulas
RangeFormula
B39B39=IF(MONTH(A39)<7,YEAR(A39),YEAR(A39)+1)
B40B40=YEAR(A39)+IF(MONTH(A39)<7,0,1)
 
Upvote 0
2nd formula calculates the YEAR then adds 0 or 1 depending on the month value.
 
Upvote 0
Not sure if you realised. but this is in the Access part of the site, not Excel.
 
Upvote 0
I don't think you can put formulas in the Default Value of Table Fields in Microsoft Access.
You really shouldn't anyway, as that would violate the Rules of Normalization (any value that can be calculated form other values in the table should NOT be stored as a hard-coded value).
Since it can be calculated, simply add that calculated field to a query on that table.
 
Upvote 0
Solution
Not sure if you realised. but this is in the Access part of the site, not Excel.
Yes its an access question. I an trying to put an expression as a default value in a field.
 
Upvote 0
As a follow-up to my previous reply, note that newer versions of Access allow you to do calculated fields in Tables, but it is highly advised NOT to do this, and to do it in queries instead.
Here is an article which discusses that: Why One Should Use Queries instead of Calculated Fields for Access Tables.

Another reason not to is that it violates the Rules of Normalization, and other database programs like SQL do not allow this, so if you ever need to convert the database or interact with the database programs, you will probably have issues.

Simple rule of thumb to follow: Never store in a table that which can easily be calculated in a query.
There is seldom ever a need to. You can use a Query for almost anything that you use a Table for.
 
Upvote 0
As a follow-up to my previous reply, note that newer versions of Access allow you to do calculated fields in Tables, but it is highly advised NOT to do this, and to do it in queries instead.
Here is an article which discusses that: Why One Should Use Queries instead of Calculated Fields for Access Tables.

Another reason not to is that it violates the Rules of Normalization, and other database programs like SQL do not allow this, so if you ever need to convert the database or interact with the database programs, you will probably have issues.

Simple rule of thumb to follow: Never store in a table that which can easily be calculated in a query.
There is seldom ever a need to. You can use a Query for almost anything that you use a Table for.
Awesome, good information. Thank you
 
Upvote 0

Forum statistics

Threads
1,215,147
Messages
6,123,296
Members
449,095
Latest member
Chestertim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top