We help IT Professionals succeed at work.
Get Started

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

Murray Brown
Murray Brown asked
on
52 Views
Last Modified: 2019-12-04
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
IT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE