Constructing a combobox's Row Source

C

cinnie

I'm really not sure how to approach this. I have an unbound combobox on my
form. I want the entries in the combobox to be Excursion #1, Excursion #2
..... etc, (always in sequential order starting from 1). The last entry is
based on a value taken from a hidden textbox txtExcursionNum on the form. If
its value is, say, 12, then the last entry in the combobox should be
Excursion #12. How do I get the Row Source to 'adjust' like this?

thanks in advance
cinnie
 
K

kingston via AccessMonster.com

Where does the hidden textbox get its value? Since it is hidden, you can't
use its AfterUpdate event. So, trace the process back a step or two to find
an event that can be used as a trigger. For example, if the textbox is
populated by a control on another form, use an event from that control to
change the combobox's .RowSource property. The row source type must be a
Value List.

Forms!FormName!ComboBoxName.RowSource = "Excursion #1; Excursion #2..."

Formulate the RowSource string with something like:

string = "Excursion #1"
For i = 2 to hiddentext
string = string & "; Excursion #" & i
Next i
 
F

fredg

I'm really not sure how to approach this. I have an unbound combobox on my
form. I want the entries in the combobox to be Excursion #1, Excursion #2
.... etc, (always in sequential order starting from 1). The last entry is
based on a value taken from a hidden textbox txtExcursionNum on the form. If
its value is, say, 12, then the last entry in the combobox should be
Excursion #12. How do I get the Row Source to 'adjust' like this?

thanks in advance
cinnie

Add a table to your database.
tblExcursionCount
ID AutoNumber No Duplicates
ExcursionName Text

Enter as many excursion names as you will ever need to use.
Let's say 20.
1 ExcursionName1
2 ExcursionName 2
3 ... etc
20 ExcursionName20

Then add your combo box to the form
Set it's RowsourceType property to Table/Query
Set it's Rowsource to:
Select ID, ExcursionName From tblExcursionCount Where ID <=
[YourHiddenControlName];

This gives you an easy update if you get additional excursions in the
future. Just add the excursion name to the table.

If the value in the hidden control is 8, the combo will display
excursions 1 through 8.

If the control is not visible, how are you getting the value into it?
 
Top