Trying to show all columns in Combo box

  • Thread starter Thread starter mokihi
  • Start date Start date
M

mokihi

I have the following dataset in columns

A1 A2 A3 A4
Unit number Unit title Level Credits
4098 Test title 1 4

I have made these values into a table of their own and have created a
combination box so I can choose one of the records. Only problem is, the
result will only show the unit number and not columns A2, A3, and A4. Can
someone tell me how to get this information all showing so that when I choose
the unit number, it automatically populates the Unit Title, Level and Credits?
 
I take it that for any Unit number, the Unit Title, Level, and Credits
*never* change?

If so you need a table to define the units, with just these fields:
- UnitNum Number primary key
- UnitTitle Text required, unique
- UnitLevel Number
- Credits Number
Each unit appears only once in this table.

Now you have another table where the UnitNum can occur many times (e.g. lots
of students taking the unit.) In this table, you do *not* have the
UnitTitle, UnitLevel, or Credits fields -- just the UnitNum field. That way
you can't end up with bad data (e.g. where 4098 is recorded as "English"
when it should be "Test title".)

You can now create a query joining the 2 tables, so it will show the
UnitTitle, UnitLevel, and Credits (from the Unit table), as well as the
fields from your main table.
 
A combo box only shows a single field once selected. You can use a list box
to show multiple fields, or set unbound textboxes equal to the value in the
other columns, like A2 is column(1) so, you would use code like:

Private Sub cboMyCombo_AfterUpdate()
Me.[txtUnitTitle] = Me.cboMyCombo.Column(1)
Me.txtLevel = Me.cboMyCombo.Column(2)
Me.txtCredits = Me.cboMyCombo.Column(3)
End Sub
 
Back
Top