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

Murray Brown
Murray Brown used Ask the Experts™
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software & Systems Engineer
And where you have issue...Combo and Listbox seems to share the same RowSourceType,Widths...etc
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
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.
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thanks
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial