G
Guest
Sorry for reposting this, just wanted to see what I might be coding
incorrectly:
A user selects the month in a "Month" combo box and types in the year in a
"Year" text box.
What I would like to have happen is when both fields are completed, the
NextMonth field gets filled in automatically.
Currently I have the following subs coded:
Private Function dteNextMonth(dteFDate As Date) As Date
'find first day of the month
dteNextMonth = DateValue(DatePart("m", dteFDate) & "/1/" & DatePart("yyyy",
dteFDate))
'add two months
dteNextMonth = DateAdd("m", 2, dteNextMonth)
'Subtract one day
dteNextMonth = DateAdd("d", -1, dteNextMonth)
End Function
Private Sub NextMonth_AfterUpdate()
NextMonth.DefaultValue = "#" & dteNextMonth([Month] & "/1/" & [Year]) & "#"
End Sub
Private Sub NextMonth_BeforeUpdate()
NextMonth.DefaultValue = "#" & dteNextMonth([Month] & "/1/" & [Year]) & "#"
End Sub
Thanks again for your help so far,
incorrectly:
A user selects the month in a "Month" combo box and types in the year in a
"Year" text box.
What I would like to have happen is when both fields are completed, the
NextMonth field gets filled in automatically.
Currently I have the following subs coded:
Private Function dteNextMonth(dteFDate As Date) As Date
'find first day of the month
dteNextMonth = DateValue(DatePart("m", dteFDate) & "/1/" & DatePart("yyyy",
dteFDate))
'add two months
dteNextMonth = DateAdd("m", 2, dteNextMonth)
'Subtract one day
dteNextMonth = DateAdd("d", -1, dteNextMonth)
End Function
Private Sub NextMonth_AfterUpdate()
NextMonth.DefaultValue = "#" & dteNextMonth([Month] & "/1/" & [Year]) & "#"
End Sub
Private Sub NextMonth_BeforeUpdate()
NextMonth.DefaultValue = "#" & dteNextMonth([Month] & "/1/" & [Year]) & "#"
End Sub
Thanks again for your help so far,