Populate the row source of a combo box

S

SHIPP

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?
 
G

Graham Mandeno

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top