MCTampa
Board Regular
- Joined
- Apr 14, 2016
- Messages
- 97
I have a text box called Current that populates todays date on load.
I want the next text two text boxes (Prior and Y2) to populate the same day prior year and the same day two year's ago by looking up those dates off of a table.
I don't want to do date()-365 and date()-728 because I want the user to be able to select a different date in the Current box.
On button click I want Prior and Y2 to update.
I'm using the following sub (trying to solve for Prior for the moment).
My "Dates" table runs from 1/1/2021 through 12/31/2021 and has two columns Year1 and Year2 which run from 1/3/2020 and 1/4/2019.
Today, the current box populates with 5/25/2021 and when I press my button, I only get 1/3/2020 for my Prior box.
Not sure what I'm doing wrong with the formatting, but evidently something is amiss.
Thanks,
Mike
I want the next text two text boxes (Prior and Y2) to populate the same day prior year and the same day two year's ago by looking up those dates off of a table.
I don't want to do date()-365 and date()-728 because I want the user to be able to select a different date in the Current box.
On button click I want Prior and Y2 to update.
I'm using the following sub (trying to solve for Prior for the moment).
VBA Code:
Private Sub Command7_Click()
Prior = DLookup("[Year1]", "Dates", "#" & Format(Forms!Form1![Current], "mm\/dd\/yyyy\") & "#")
End Sub
My "Dates" table runs from 1/1/2021 through 12/31/2021 and has two columns Year1 and Year2 which run from 1/3/2020 and 1/4/2019.
Today, the current box populates with 5/25/2021 and when I press my button, I only get 1/3/2020 for my Prior box.
Not sure what I'm doing wrong with the formatting, but evidently something is amiss.
Thanks,
Mike