Increment years

J

Jenn Civello

I have a form that I need to have a field that increments by several
different numbers. I already have this formula working for 7 years, but I
need to add other years to the formula. Can you please let me know what I
need to change the formula to.
=DateSerial(Year([StartDate])+7,Month([StartDate]),Day([StartDate]))

Thanks
Jenn
 
B

babyatx13 via AccessMonster.com

Jenn said:
I have a form that I need to have a field that increments by several
different numbers. I already have this formula working for 7 years, but I
need to add other years to the formula. Can you please let me know what I
need to change the formula to.
=DateSerial(Year([StartDate])+7,Month([StartDate]),Day([StartDate]))

Thanks
Jenn

Don't hard code #'s, instead of 7 use a table with the numbers you want to
use and look them up.
DLookup("Field", "Table", "Record #") in the place of "7"
=DateSerial(Year([StartDate])+DLookup("Field", "Table", "Record #") ,Month(
[StartDate]),Day([StartDate]))


K Board
 
J

John W. Vinson

I have a form that I need to have a field that increments by several
different numbers. I already have this formula working for 7 years, but I
need to add other years to the formula. Can you please let me know what I
need to change the formula to.
=DateSerial(Year([StartDate])+7,Month([StartDate]),Day([StartDate]))

Thanks
Jenn

I guess I don't understand your question. Where did the 7 come from?
Where do you WANT the number of years to come from? A form control? a
user prompt? A VBA variable?

John W. Vinson [MVP]
 
J

Jenn Civello

Does it matter if her have the "Record #" in the formula? We took it out,
and we are getting this error. "#Name?". Our formula is
=DateSerial(Year([StartDate])+DLookUp("# of Years to be
Archived","DestructionYear"),Month([StartDate]),Day([StartDate])). # of
years to be archived is the field and Destruction Year is the table. What
are we doing wrong?


babyatx13 via AccessMonster.com said:
Jenn said:
I have a form that I need to have a field that increments by several
different numbers. I already have this formula working for 7 years, but I
need to add other years to the formula. Can you please let me know what I
need to change the formula to.
=DateSerial(Year([StartDate])+7,Month([StartDate]),Day([StartDate]))

Thanks
Jenn

Don't hard code #'s, instead of 7 use a table with the numbers you want to
use and look them up.
DLookup("Field", "Table", "Record #") in the place of "7"
=DateSerial(Year([StartDate])+DLookup("Field", "Table", "Record #")
,Month(
[StartDate]),Day([StartDate]))


K Board
 
B

babyatx13 via AccessMonster.com

Jenn said:
Does it matter if her have the "Record #" in the formula? We took it out,
and we are getting this error. "#Name?". Our formula is
=DateSerial(Year([StartDate])+DLookUp("# of Years to be
Archived","DestructionYear"),Month([StartDate]),Day([StartDate])). # of
years to be archived is the field and Destruction Year is the table. What
are we doing wrong?
[quoted text clipped - 13 lines]

Your DLookup needs to refer to a table with years in it

Example:
tblYears
KYrID NoOfYears
AutoNumber Number

DLookup("Field", "Table", "Record #")
DLookup("NoOfYears", "tblYears", "KYrID")

If you would like you can have this table only hold one record and just
change the NoOfYears for each report, in which case your DLookup would look
like this.

DLookup("NoOfYears", "tblYears", "001â€)


K Board
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top