Form control value based on combo box

J

Jaime

I have the following:

Form: frmAccountBalance
Table: tblAccountBalance
fields in this table are account, description, Jan, Feb, Mar, etc

I am creating a form where I want a combo box value determine which field is
displayed in the form. I have account, description, and balance in the form
as controls. If the combo box value is Jan, I want to be able to display the
balance for that table field. Also, when the combo box is changed to Feb, I
would like to see the control change the values to display Feb balances.

Please help. Thanks

Jaime
 
M

Marshall Barton

Jaime said:
I have the following:

Form: frmAccountBalance
Table: tblAccountBalance
fields in this table are account, description, Jan, Feb, Mar, etc

I am creating a form where I want a combo box value determine which field is
displayed in the form. I have account, description, and balance in the form
as controls. If the combo box value is Jan, I want to be able to display the
balance for that table field. Also, when the combo box is changed to Feb, I
would like to see the control change the values to display Feb balances.


Use the combo box's AfterUpdate event procedure to set the
text box's value:

Me.textbox = Me(Me.combobox)
 
J

Jaime

Thanks for the quick response. It doesn't seem to work correclty. The table
has 2000 accounts and each have balances for Jan, Feb, and Mar. The form
lists all of the account with zero even though there are amounts in the table.
By control "Balance" control is unbound. What else am I missing?
 
M

Marshall Barton

Jaime said:
Thanks for the quick response. It doesn't seem to work correclty. The table
has 2000 accounts and each have balances for Jan, Feb, and Mar. The form
lists all of the account with zero even though there are amounts in the table.
By control "Balance" control is unbound. What else am I missing?


Does "form lists all of the account" mean that it a
continuous form? If so, an unbound text box will not work.
However, you can bind the text box to the field named by the
combo box:
Me.textbox.ControlSource = Me.combobox
which should also work in any situation. If you do not want
users to modify the value, set the text box's Locked
property.

Double check that the combo box's bound column is the field
name the user selects.
 

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