DJ_DEF_CON_1
Registered User.
- Local time
- Today, 08:23
- Joined
- Jan 1, 2003
- Messages
- 40
I have a combo box that has the twelve month's listed in it's row source. This combo box populates two text boxes when selected (Start and End dates for the form) I have it sort of working the way I like. When you select the present month, it populates the fields correctly. This is good. What I would like it to do is, when you select any other month I would like it to populate the text boxes with last years dates. i.e. Today is February 4, 2003 and I select January, I would like it to populate 01/01/03 and 01/31/03, if I select November I would like it to populate 11/01/02 and 11/30/02. I have some code (That I'll copy you) that sort of works but not totally. Any help would be greatly appreciated.
Private Sub Combo2_AfterUpdate()
Dim aDate As Date
If Month("01/" & Me.Combo2 & "/" & Year(Date)) = Month(DateAdd("m", 1, Date)) Then
aDate = DateAdd("m", 1, Date)
Else
aDate = DateAdd("m", -CInt(Month("01/" & Me.Combo2 & "/" & Year(Date)) - Month(Date)), Date)
End If
Me.START_DATE = StartOfMonth(aDate)
Me.END_DATE = EndOfMonth(aDate)
End Sub
If it is the current month, then I want to get the current month.
Otherwise I would like to get last years month.
Private Sub Combo2_AfterUpdate()
Dim aDate As Date
If Month("01/" & Me.Combo2 & "/" & Year(Date)) = Month(DateAdd("m", 1, Date)) Then
aDate = DateAdd("m", 1, Date)
Else
aDate = DateAdd("m", -CInt(Month("01/" & Me.Combo2 & "/" & Year(Date)) - Month(Date)), Date)
End If
Me.START_DATE = StartOfMonth(aDate)
Me.END_DATE = EndOfMonth(aDate)
End Sub
If it is the current month, then I want to get the current month.
Otherwise I would like to get last years month.