Populate the row source of a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to populate the row source of a combo box with the last 5 years.

2004
2003
2002
2001
2000

This would be on an on-going basis and would change from year to year.
Anybody know how to do this?
 
Set the RowSourceType of your combo to "Value list".

In your Form_Load event procedure, add the following code:

Dim iCount as Integer, sYearList as String
For iCount = 0 to 4
sYearList = sYearList & Year(Date) - iCount & ";"
Next
' strip off the last ";" and set the RowSource
[ComboBoxName].RowSource = Left(sYearList, Len(sYearList)-1)
 
Back
Top