Passing a comboBox to function byRef not working - getting it's Value instead
Posted on 2005-05-07
I want to pass a comboBox to a procedure, as a combobox. Here is the calling procedue:
Private Sub cboEntity1_AfterUpdate()
Dim targetCbo As ComboBox, currentCbo As Object
Set targetCbo = Me.cboEntity2
Set currentCbo = Me.cboEntity1
If Not SetEntityComboBox(targetCbo, currentCbo.Column(0), Me.lblEntity2, Me.lblStatus) Then
UpdateLists (currentCbo)<------------------------------------it's taking it's value, not it's rference to the combobox!!!
Here is the procedure:
Private Sub UpdateLists(ByRef aComboBox As ComboBox)
On Error GoTo UpdateLists_Error
' update unassigned people
Call SetEmployeeRelatedListBox(lstUnassignedPeople, m_relatedFieldName, Null)
If wasChangeMade Then
' update assigned people
m_relatedFieldID = aComboBox.Column(0)
Call SetEmployeeRelatedListBox(lstAssignedPeople, m_relatedFieldName, m_relatedFieldID)
' set related fields
Me!txtSpecialPerson = aComboBox.Column(1)
Me!lblStatus.Caption = ""
' establish the count so we can know if changes were made the next time
m_assignedCount = lstUnassignedPeople.ListCount
As you can see, I need the comboBox to be acting as a comboBox in here, but I'm getting it's currently selected value. What's interest is that in the procedure call imdiately above, I'm also passing it as a combobox, and in that procedure, it recognizese it as such. I'm confused.
I guess I could pass the name as a string and refer to it as part of the form's controls collection, but I don't want to do that if I don't have to.