VB - How to set unbound Combobox Item for two column variables
Posted on 2014-01-14
I have a form which has several unbound comboboxes.
In the VB code I set the rowsource of the various comboboxes.
I also have a listbox of existing records where on that listbox's DblClickEvent I go to the Record and update the various unbound comboboxes with the info from that record.
However, one of the comboboxes could have multiple values if I use only one of the rowsource's fields to select by. Is there a way to do it with two?
One of my comboboxes is cboSelectCounty.
My Rowsource is set in the VB code. When the listbox is double clicked I have the code
Private Sub lstExistingRecs_DblClick(Cancel As Integer)
Dim b as long
b = Me.lstExistingRecs.Column(1) ' CountyCodeID
me.cboselectcounty = b
Everything above works fine as does what I want it to....
HOWEVER, for combobox [cboSelectBkNbrSubBkNbr] the rowsource is set as
"SELECT CountyCodeID, RecBkTypeID, RecBkNbrID, RecBkNbrSubID, BkNbrWhole, RefBk FROM qrySys_ValidRecBkTypeRecBkNbrBkNbrSubByCounty "
When I double click the Listbox I want the selection in [cboSelectBkNbrSubBkNbr] to be based on:
I know I can do the RowSource "WHERE RecBkNbrID=x AND RecBkNbrSubID=y"
but then the drop down list will only show that one particular line if the user needs to change it.
Is there a way to get that one field selected and showing in the combobox without limiting the list to just that one when I'm using 2 variable?