Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CommandButton to populate current month in textbox

Status
Not open for further replies.

Mandyxoxo

Programmer
Jul 15, 2008
11
US
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!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top