getting value of unbound column in combo box

  • Thread starter Thread starter karen via AccessMonster.com
  • Start date Start date
K

karen via AccessMonster.com

I have a main form and a sub form that are currently linked as follows
Master: combo box 1st column (the bound column)
Child : OrderNo
The combo box is called cboOrder.

This works fine, but I need to also link the 2nd column from the combo box
to a child field OrderType. I tried
Master:cboOrder;cboOrder.column(1)
Child:OrderNo;OrderType

I get an error on cboOrder.column(1). How can I do this? I also tried to
set the value of the subform field OrderType on the ONCURRENT event of the
cboOrder combo box, but got error saying can't find [sub form name]. I
verified that I spelled the sub form name correctly. What am I doing wrong?
 
Simplest solution (code-free) might be to use a query as the RecordSource of
the main form, and include the combo's RowSource table.

1. Create a query into the table you use for the main form.
Drag the * into the grid.
Specify any sorting you need.

2. In query design, and the table that feeds the combo's RowSource.
Drag the field or the combo's 2nd column into the grid.

3. Double-click the line joining the 2 tables in the upper pane of the query
design window. Access pops up a dialog with 3 options. Choose the one for:
All records from my form's table, and any matches from combo's table.

4. Save the query, and set the form's RecordSource to this query.

There is one quirk you may need to work around. If you now have a problem
adding record to the main form, you may need to remove any Default Value set
on the fields of the combo's RowSource table. Access misunderstands this
Default Value, and tries to create a record in the lookup table as well.
 
Back
Top