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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set combo box default to current month and year?

Status
Not open for further replies.

MaddiMond

Technical User
Mar 28, 2005
76
0
0
US
I have an unbound Combo Box in a form set to display Month and Year only. The value of this combo box determines which month is shown in the report.

The row source of the combo is:

SELECT DISTINCT Format([tblSales].[SignedDate],"yyyymm") AS Expr1, Format([tblSales].[SignedDate],"mmmm yyyy") AS Expr2 FROM tblSales ORDER BY Format([tblSales].[SignedDate],"yyyymm"), Format([tblSales].[SignedDate],"mmmm yyyy");

Of course, the list of months and years in there gets longer and longer. How can I make it easier for the user? I tried it this way, I used [comboboxname].ItemData(n) to set the default value of the combo to the desired month and year, but this will have to be changed manually all the time. Can I set the default value to the current month and year? I tried [comboboxname].Date(), but since I was unsuccessful, I think this is probably not possible.

I also tried ActiveX Calendar 9.0 and played around with it. I recognized a couple of things. First, the calendar seems not to work in datasheet view. Also, is there a calendar version that lets one choose month and year only, not including the day?

Your help is appreciated.

Maddi
 
How about:

Code:
Private Sub Form_Current()
Me.cboCombo = Format(Date, "yyyymm")
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top