Solved

VB - How to set unbound Combobox Item for two column variables

Posted on 2014-01-14
2
764 Views
Last Modified: 2014-01-14
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?
0
Comment
Question by:wlwebb
2 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39779901
You could modify the RowSource for the combo and concatenate those two fields into a single computed field and make that the first field in the combo box (bound column) and hide it.  something like:

SELECT [RecBnNbrID] & "|" & [RecBnNbrSubID] as Key, CountyCodeID,
RecBkTypeID, RecBkNbrID, RecBkNbrSubID, BkNbrWhole, RefBk
FROM qrySys_ValidRecBkTypeRecBkNbrBkNbrSubByCounty

Then, in the double click event, you would concatenate those values in your list, something like:

me.cboSelectBkNprBusBkNbr = Me.lstExistingRecs.Column(0) & "|" & me.lstExistingRecs.column(1)
0
 

Author Closing Comment

by:wlwebb
ID: 39779966
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!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question