Date Add Code

gripper

Board Regular
Joined
Oct 29, 2002
Messages
176
On my MS Access DB I have a form and on that form their is a date field named "txt_Date_Purchased".

I am trying to make an After Update code that will automatically add 365 days to this field and put the results in the field "txt_Expiration_Date".

Below is the code I constructed but it does not work. Can you guys see what I did incorrectly.


Private Sub txt_Date_Purchased_AfterUpdate()
Me.txt_Date_Purchased.Value = DateAdd("d", 365, Me.txt_Expiration_Date.Value)
End Sub

Thank you.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Looks like you have you two fields backwards.
You are telling it to update "txt_Date_Purchased" after it "txt_Date_Purchased" updates!
Looks like an endless loop to me!

Don't you want to update "txt_Expiration_Date" after "txt_Date_Purchased" updates? If so, you need to switch those two fields in your formula.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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