423,682 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,682 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".)
Sep 13 '18 #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,907
Here is a link to the description of the DateAdd() Function.
Sep 13 '18 #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])
Sep 13 '18 #3

Seth Schrock
Expert 2.5K+
P: 2,907
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.
Sep 13 '18 #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!
Sep 13 '18 #5

Seth Schrock
Expert 2.5K+
P: 2,907
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]) 
Sep 13 '18 #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!!
Sep 13 '18 #7

Post your reply

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