View Full Version : need help with form coding for current month in Access

05-19-2006, 05:45 PM
Can someone help?

I have this code that I am trying to use in a form to have the form display the current month from the 1st day to the last - the problem is that is does not display the current setting correctly.

Private Sub cmdmonth_Click()
'Sets the Date From and Date To text boxes
'to show complete month (from start to end of current month)

Me!txtdatefrom = CDate("01/" & Month(Date) & "/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtdatefrom))

When I click the Month button in the form the results displayed are:
Date From: 1/5/2006
Date To: 2/4/2006

When it should display:

Date From: 5/1/2006
Date To: 5/31/2006

Can someone help me adjust the code above?