Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access use multi column ListBox on popup form to load multicolumn source combobox

Hi

I am using the following code behind a button click to open a form whose code is shown further on. This loads a listbox on the form.
When the user makes a selection from the listbox it sends this back to my original ComboBox.
The listbox has one column. I now want to do this for a multi column combobox and listbox. How do I do that?
Thanks

Private Sub btnManufacturer_Click()

    oForm = Me.Name
    oCombo = Me.Manufacturer_Combo.Name
    DoCmd.OpenForm "f_List", , , , , acDialog

End Sub

Open in new window


Private Sub Form_Open(Cancel As Integer)


  Cancel = -1
  CopyComboBoxSettings Forms(oForm).Form.Controls(oCombo)

  Cancel = 0

End Sub


Private Sub CopyComboBoxSettings(ByVal CSourceComboBox As Access.ComboBox)

  List1.RowSourceType = CSourceComboBox.RowSourceType
  List1.RowSource = CSourceComboBox.RowSource
  List1.ColumnCount = CSourceComboBox.ColumnCount
  List1.ColumnWidths = CSourceComboBox.ColumnWidths

End Sub


Private Sub List1_Click()
    Forms(oForm).Form.Controls(oCombo).value = List1.value
    DoCmd.Close
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not sure why you think you need to do this.  What do you gain over simply using the original combobox to make a selection?

You can use a multi-column rowsource for the combo box.
Avatar of Murray Brown

ASKER

Thanks
But why do you want to do this instead of simply using a multi-column combo box on the main form?

Still don't understand this logic.