HELP PLS!! -- assign values into combo box

G

Guest

Hi,

I'm using Access 2000 trying to do some vba here.
Had no idea how izit possible to assign these values into a combo box.

I have a table with 2 fields that contains (1) Start_Year (2) End_Year both
contain integer.
So i have a query which select these 2 values out.
I will have to use a loop (or some thing) to get the numbers from the
<Start_Year> to <End_Year>.
Then I need to pop all these values into a combo box with one column, that
contains all the values starting from <Start_Year> to <End_Year>.

How do I programme it??
Izit with the Form_Load()? As once the user open the form, the combobox
should already contain values ready for selection.
Or Combo_BeforeUpdate()?

Can someone please help me!!

Thanx a Million...

RegarDx...
 
D

Douglas J Steele

Form_Load is probably the most appropriate place.

Easiest way would be:

Dim intYear As Integer
Dim strYears As String

For intYear = Start_Year To End_Year
strYears = intYear & ";"
Next intYear

' Remove the final semi-colon
strYears = Left(strYears, Len(strYears)-1)

Me.MyComboBox.RowSourceType = "Value List"
Me.MyComboBox.RowSource = strYears

Replace "MyComboBox" with whatever your combo box is named. (I assume you
know how to retrieve the values for Start_Year and End_Year.)
 

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