HeelNGville
Registered User.
- Local time
- Today, 17:37
- Joined
- Apr 13, 2004
- Messages
- 71
Preface this with thanks for any assistance in resolving or guidance, as I am sure this is simple but my VBA is limited at best.
Basically, I have a DB form with a calendar date picker for a user to select a beginning date (txtClick1) and ending date (txtClick2), with the on current properties set to default to the 1st of the month for the beginning date and the ending date set to default to current date -1 (this value is always ok) for MTD reporting purposes.
What I need assistance with is, when Day =1 (first of each month), I would like for the txtClick1 value to default to the 1st day of the previous month. Ex. On 4/1/2020, a user opens the DB and forms loads with txtClick 1 as 3/1/2020 and txtClick2 would be 3/31/2020 . On 4/2, the txtClick1 value would be 4/1/2020. Only on day 1 would the code need to revert to previous month.
Below is the quick snippet of the
Thanks in advance!
Basically, I have a DB form with a calendar date picker for a user to select a beginning date (txtClick1) and ending date (txtClick2), with the on current properties set to default to the 1st of the month for the beginning date and the ending date set to default to current date -1 (this value is always ok) for MTD reporting purposes.
What I need assistance with is, when Day =1 (first of each month), I would like for the txtClick1 value to default to the 1st day of the previous month. Ex. On 4/1/2020, a user opens the DB and forms loads with txtClick 1 as 3/1/2020 and txtClick2 would be 3/31/2020 . On 4/2, the txtClick1 value would be 4/1/2020. Only on day 1 would the code need to revert to previous month.
Below is the quick snippet of the
Code:
Private Sub Form_Current()
Me.txtClick1.Value = DateSerial(Year(Date), Month(Date), 1)
Me.txtClick2.Value = Date - 1
End Sub
Thanks in advance!