ComboBox/DLookup

T

theryno

I have a combo box and I am trying to update 5 other fields based upon the
selection from the combo box. I want the values that are updated to be
stored within the current table. I am using DLookup, but no matter which
selection is made, itthe fields it updates default to a certain record (which
is not related to the selection). It also uses these values for every record
no matter what the selection. Any suggestions?
 
W

Wayne Morgan

First, if the values you are trying to store are located in the same table
as the Row Source for the combo box, then all you need to store is the
unique id field of the record selected by the combo box. Use a query to
combine the form's table and the combo box's table when you want the other
information in a report or other output item.

The reason you're seeing what you are in the form is because the textboxes
displaying the values are unbound so they don't automatically update when
you move from one record to another. You can code them to do so, but there
is a better option. Return the other values you want displayed on the form
in the combo box's Row Source. Hide the columns you don't want the combo box
to display, then set these textboxes to display the values of the hidden
columns that you want to see.

Example Control Source for the textboxes:
=cboMyCombo.Colunn(2)

The column index number is zero based, so 0 is the first column, 1 is the
second, 2 is the third, etc.

The Bound Column of the combo box should be the column that contains the
unique id field from the combo box's Row Source table or query. The combo
box's Control Source should be the field in the form's Record Source that
you want this ID stored in.
 
Top