Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box questions

Status
Not open for further replies.

obheron

Technical User
May 25, 2005
40
US
Hi all,
I have a series of combo boxes on a form that I wish to be dependent on each other in this way.

1. C1 - no dependancies
2. C2 - list is filtered by option in chosen in C1

The above part I have working.

3. C3 - I want the combobox list to have 2 values, these values need to be the value chosen in C1 and the value in C2.

4. C4 - can be like C3 if I can't do this next part.
C4 is dependant on C3 in that it should be
whichever value was not chosen in C3

Concept:
C1 and C2 are the users choices for pieces of hardware.
C3 and C4 allow the user to choose the source and destination of the signals between the pieces of hardware.

Can it be done? Thanks in advance.
 
Why do you need C4? If its only purpose is to hold the single value *not* selected from C3, it is not needed. It could be a textbox (if you need to see the value on the form) or nothing at all - just process the data for the non-selection in C3's AfterUpdate event.

So, for C3... set its rowsource type to value list, but leave the row source field blank. Then use the AddItem method in C2's AfterUpdate event to add the values from C1 and C2 to C3's rowsource. Then in C3's AfterUpdate event, since you're selecting between only 2 possible choices, you can refer directly both to the value of combo for the selected value, and to the ItemData property and index of the item NOT selected. This little bit of code demonstrates how you might refer to the non-selected item in a combo that only has two choices:
Code:
Dim i As Integer
Dim strMyString As String
i = Choose(Me!Combo0.ListIndex + 1, 1, 0)
strMyString = Me!Combo0.ItemData(i)
MsgBox "Item NOT selected is " & strMyString
HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top