wlwebb
asked on
VB - How to set unbound Combobox Item for two column variables
Hello All,
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?
For Example.
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(C ancel As Integer)
Dim b as long
b = Me.lstExistingRecs.Column( 1) ' CountyCodeID
me.cboselectcounty = b
end sub
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_ValidRecBkTypeRecBk NbrBkNbrSu bByCounty "
When I double click the Listbox I want the selection in [cboSelectBkNbrSubBkNbr] to be based on:
RecBkNbrID
AND
RecBkNbrSubID
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?
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?
For Example.
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(C
Dim b as long
b = Me.lstExistingRecs.Column(
me.cboselectcounty = b
end sub
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_ValidRecBkTypeRecBk
When I double click the Listbox I want the selection in [cboSelectBkNbrSubBkNbr] to be based on:
RecBkNbrID
AND
RecBkNbrSubID
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the Help!