I have a form with a button that puts the beginning and ending date in two textboxes. The start date is named Start_Date_Corp and the stop date is named Stop_Date_Corp. I would like to have another textbox that looks at the Start date and populates with a date that is 24 months prior to that date. Below is the VBA I have but I cannot make it work correctly. When I push the 2013 the first two boxes are correct - Start_Date_Corp 1/1/2013 -- Stop_Date_Corp 12/21/2013. The start date textbox I have for 24 months prior displays 1/1/1898. How can I make this box come up with the correct date? Or maybe just have that textbox look at the start date and then update using a function on the form?
Below is my VBA
Function Set_Metrics_24_month_Corp()
Dim Start_Date_Corp As Date
Dim Stop_Date_Corp As Date
Corp_Metric_2Yr_Stop = DateSerial(Year(Stop_Date_Corp), Month(Stop_Date_Corp) + 1, 0) + TimeSerial(23, 59, 59)
Corp_Metric_2Yr_Start = DateSerial(Year(Start_Date_Corp), Month(Start_Date_Corp) - 23, 1)
Forms![frm_Main]![NavigationSubform].Form![Corp_Metric_2Yr_Start].Value = Corp_Metric_2Yr_Start
Forms![frm_Main]![NavigationSubform].Form![Corp_Metric_2Yr_Stop].Value = Corp_Metric_2Yr_Stop
End Function
Below is my VBA
Function Set_Metrics_24_month_Corp()
Dim Start_Date_Corp As Date
Dim Stop_Date_Corp As Date
Corp_Metric_2Yr_Stop = DateSerial(Year(Stop_Date_Corp), Month(Stop_Date_Corp) + 1, 0) + TimeSerial(23, 59, 59)
Corp_Metric_2Yr_Start = DateSerial(Year(Start_Date_Corp), Month(Start_Date_Corp) - 23, 1)
Forms![frm_Main]![NavigationSubform].Form![Corp_Metric_2Yr_Start].Value = Corp_Metric_2Yr_Start
Forms![frm_Main]![NavigationSubform].Form![Corp_Metric_2Yr_Stop].Value = Corp_Metric_2Yr_Stop
End Function