423,350 Members | 2,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,350 IT Pros & Developers. It's quick & easy.

Access 2013: Use DateAdd to calculate based on button click

P: 4
Creating a database to track training. I have a form in which an original certification date is entered. From that date, I need to add 1, 2, or 3 years to determine the due date for re-certification (a separate field) based on the button that is clicked ("1 year", "2 year", or "3 Year".)
1 Week Ago #1

✓ answered by Seth Schrock

If you are doing it in the property sheet, then you need to remove everything to the left of the equals sign. If you are wanting to do it in the button's OnClick event, then you will need to do something like the following:
Expand|Select|Wrap|Line Numbers
  1. Me.ControlName= DateAdd ("yyyy",1,[Certification_Date]) 

Share this Question
Share on Google+
6 Replies


Seth Schrock
Expert 2.5K+
P: 2,895
Here is a link to the description of the DateAdd() Function.
1 Week Ago #2

P: 4
thanks for the reply Seth. I have that info, but it doesn't work. Not sure if I am putting it in the right location or not. I tried putting it in the "On click"for the button, but I get an error about it being a macro:
Expand|Select|Wrap|Line Numbers
  1. [Re-Certification_Date]= DateAdd ("yyyy",1,[Certification_Date])
1 Week Ago #3

Seth Schrock
Expert 2.5K+
P: 2,895
Are you doing this in code or in a macro? I would highly recommend using code and not a macro.

Also, please provide the exact error message along with the number if provided.
1 Week Ago #4

P: 4
I had done this in the "Property sheet". I used Access on a regular basis, a hundred years ago, but have been away from it for so long I think I have forgotten everything, lol.

The Exact Error is:
Microsoft Access cannot find the object '[Re-Certification_Date]= DateAdd ("yyyy",1,[Certification_Date]).'

If '[Re-Certification_Date]= DateAdd ("yyyy",1,[Certification_Date])' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly.


There is no number associated with the error.

Thanks again!
1 Week Ago #5

Seth Schrock
Expert 2.5K+
P: 2,895
If you are doing it in the property sheet, then you need to remove everything to the left of the equals sign. If you are wanting to do it in the button's OnClick event, then you will need to do something like the following:
Expand|Select|Wrap|Line Numbers
  1. Me.ControlName= DateAdd ("yyyy",1,[Certification_Date]) 
1 Week Ago #6

P: 4
You're Awesome Seth! I had forgotten all about "Me."

I just did it in the "Event Procedure" for the Button "OnClick" event and voila!!
1 Week Ago #7

Post your reply

Sign in to post your reply or Sign up for a free account.