I am trying to build a form for the user to pick date constraints. The form has two text boxes, one called txtStartDate1 and txtEndDate1. Below the two text boxes there are four command buttons. The first command button is labeled today and if pressed populates today's date in the text boxes. The second is labeled week and if pressed populates the text boxes with dates for this week (ex for this week: txtStartDate1: 7/14/2008 and txtEndDate1: 7/18/2008). The third command button is to populate the month. For example in the first text box it would populate 7/1/2008 and then find the end date for the current month. Lastly, I want to have a button with year. Both month and year do not work. I have the following code listed below and then the error that is being generated.
For Month:
txtStartDate1 = DateSerial(Year(Date), Month(Date), 1)
txtEndDate1 = DateSerial(Year(Date), Month(Date) + 1, 0)
Error: Object doesn't support this property or method.
I tested the code with a messagebox and everything works great. The problem is when I put the textbox = to the code.
For Year I have:
txtStartDate1 = CDate("01/01/" & Year(Date))
txtEndDate1 = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtStartDate1))
I still get the same error of: Object doesn't support this property or method. What am I doing wrong or what am I missing?
Any help is greatly appreciated!
For Month:
txtStartDate1 = DateSerial(Year(Date), Month(Date), 1)
txtEndDate1 = DateSerial(Year(Date), Month(Date) + 1, 0)
Error: Object doesn't support this property or method.
I tested the code with a messagebox and everything works great. The problem is when I put the textbox = to the code.
For Year I have:
txtStartDate1 = CDate("01/01/" & Year(Date))
txtEndDate1 = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtStartDate1))
I still get the same error of: Object doesn't support this property or method. What am I doing wrong or what am I missing?
Any help is greatly appreciated!