Hi everyone!
I have a situation where I am trying to load three combo boxes with the same values. (They are each on separate sheets of a multipage control, where some sheets do not have the combobox.
So, I'm using one procedure to select the comboboxes (LoadTravelerSelectors) and another to load the combobox passed as a parameter (LoadTravelerSelectorBox)
Here's the code:
Sub LoadTravelerSelectorBox(Ctl As Control)
' Configure the combobox
Dim ThisRow As Long
Dim Result As Long
Dim lx As Long
Ctl.Clear
ThisRow = FirstTraveler
Traveler = TravelerModule.ReadTravelerSpreadsheet(ThisRow, Result)
While Result = 0
Ctl.AddItem Traveler.Initials
lx = Ctl.ListCount - 1
Ctl.List(lx, 1) = Traveler.Name
Ctl.List(lx, 2) = Traveler.Status
ThisRow = ThisRow + 1
Wend
If Ctl.ListCount > 1 Then
Ctl.AddItem Ctl.ListCount
Ctl.List(lx, offsetTravelerInitials) = "All"
End If
End Sub
Sub LoadTravelerSelectors()
Dim Ctl As Control
' Load the various combobox traveler selectors
Set Ctl = Me.cboCalendarTravelerSelect
LoadTravelerSelectorBox (Ctl) <== VBA complains when trying to interpret this line
LoadTravelerSelectorBox (Me.cboCalendarTravelerSelect) <== or this (slightly different) version
Set Ctl = Me.cboDestinationTravelerSelect
LoadTravelerSelectorBox (Ctl)
Set Ctl = Me.cboTravelTravelerSelect
LoadTravelerSelectorBox (Ctl)
Set Ctl = Me.cboLodgingTravelerSelect
LoadTravelerSelectorBox (Ctl)
Set Ctl = Me.cboExpensesTravelerSelect
LoadTravelerSelectorBox (Ctl)
Set Ctl = Nothing
End Sub
The comboboxes are all configured the same. The routine to get a traveler is tested and works properly.
When I get to the first call to LoadTravelerSelectorBox, VBA hiccups with the message:
Run time error 424: Object required
Seems to me that I'm passing an object (a combobox. and expecting an object (Ctl as Control)
This must be doable (I would suppose), so what else do I need to do?
Thanks in advance for help,
Tony
Bookmarks