May 22 2012, 11:57 AM
What is wrong with this code
Private Sub ComboYears_AfterUpdate()
Stardate = "1/" & Me.ComboMonths.Column(1) & "/" & Me.ComboYears
EndDate = Day(DateSerial((Me.ComboYears.Value), Me.ComboMonths.Column(1) + 1, 1) - 1) & "/" & Me.ComboMonths.Column(1) & "/" & Me.ComboYears
May 22 2012, 12:08 PM
Since StartDate and EndDate are date/time fields, you'll have to switch the text into U.S. format and convert it into an actual date using the CDate() function. For example:
StartDate = CDate(Me.ComboMonths.Column(1) & "/1/" & Me.ComboYears)
Just my 2 cents...
May 22 2012, 12:10 PM
What is it doing that you don't want, or not doing that you do? What is the datatype of Stardate?
Note that a Date/Time value is not a text string. If you want these fields to contain a date/time value you would be better off using the DateSerial function directly:
Me.StarDate = DateSerial(Me!cboYears, Me!cboMonths.Column(1), 1)
Me.EndDate = DateSerial(Me!cboYears, Me!cboMonths.Column(1) + 1, 0)
DateSerial is smart enough to treat the zeroth day of a month as the last day of the previous month.