Avatar of wlwebb
wlwebb
Flag for United States of America 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(Cancel 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_ValidRecBkTypeRecBkNbrBkNbrSubByCounty "

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?
Microsoft Access

Avatar of undefined
Last Comment
wlwebb

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
wlwebb

ASKER
Uggh... missed that one........  Sometimes you just can't see the forest for all the trees right in front of you.........


Thank you for the Help!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy