Control Source Dependent on Combo Box

B

Brutalius

Hello,

I have a drop-down list on a form with several years (2005, 2006, 2007). I
also have a Table which has 3 columns of data (i.e. for 2005, 2006 and 2007).
I would like the control source of a single text box on the form to be
dependent on which year is selected. Any idea how to do this?

Thanks!
 
D

Damon Heron

The dropdown list is a combobox not tied to the table, correct? In other
words, you have a value list for the combo box of "2005";"2006";"2007".
In the after update event of the combobox, have this code:

Select Case YourComboboxName 'substitute your cbo name
Case "2005"
Me.Text8.ControlSource = "YourtblName.2005" 'sub your table and fieldname
Case "2006"
Me.Text8.ControlSource = "YourtblName.2006"
Case "2007"
Me.Text8.ControlSource = "YourtblName.2007"
End Select

End Sub

HTH
Damon
 
P

Piet Linden

Hello,

I have a drop-down list on a form with several years (2005, 2006, 2007).  I
also have a Table which has 3 columns of data (i.e. for 2005, 2006 and 2007).
 I would like the control source of a single text box on the form to be
dependent on which year is selected.  Any idea how to do this?

Thanks!

Sounds like a non-normalized design... 2005-7 are Years, so you should
not store those facts in column names. If you find yourself changing
your table design to add more data, it's a sure sign that your design
is flawed.
 

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