Re: How to with a combo box (to Rick and Steve)
- From: "Rick Brandt" <rickbrandt2@xxxxxxxxxxx>
- Date: Thu, 4 Sep 2008 06:23:19 -0500
Gord wrote:
I hope this is correct edicate to reply to you both on one post.
Thank you both for your replies but I don't think these will solve my
problem. In my first post I should have been more concise. What I
had meant was how one could make a second combo box make a selection
from its own list-- specifically according to its own listindex. (or
in some way equivalent to its listindex)
As Rick mentions at the bottom of his reply, I am using a multicolumn
drop down. In this case 4, but I am dislaying only the last 3. All
4 columns together form a unique 'record'. Let's call them A, B, C,
and D. The first combo's drop down shows B, C and D. The second
combo shows C, B and D. The source records for both lists come from
the same table. The row source for each combo comes from two queries
applied to this same table. The queries only differ in order to
change the column order for B and C for the combos and to apply a
little different sort order. In the end though, both drop downs
contain the same rows of data. The first combo of course will take
the value from column B (column order B, C and D) and the second from
column C (column order C, B and D). It is conceivable that there
will be two (or more) rows that have the same values in B and C. In
this case I can look at column D to determine which one I want. (there may
be a one in million chance that all three will be the same
but that is where the fourth column would be the final arbiter).
So you see, I need to select a specific row from the other combo so
that in later code that is run I can determine unambiquously which
row/record was selected. Note as well that I am wanting both combos
to work the same on each other. i.e. selecting from either combo
auto selects for the other. I am doing this for convenience sake so
I can pick what ever field is familiar to me at the time. Kind of
like looking someone up by their first name OR their last name.
I'm a newbie to databases so bear with me.
Any suggestions you care to add would be greatly appreciated.
Gord
Assuming that your first visible column is also your bound column (not clear
from your description), then you use the AfterUpdate code of each ComboBox
to set the other...
(first ComboBox code)
Me.SecondComboBox = Me.FirstComboBox.Column(1)
(second ComboBox code)
Me.FirstComboBox = Me.SecondComboBox.Column(1)
However this will not solve your problem if more than one row in each
ComboBox has that value. When a ComboBox's bound column has duplicates you
will ALWAYS end up at the first one in the list with that value (even if you
make the selection manually). Try this and you will see that even if you
pick the second, third, or tenth row having a particular value in the bound
column the ComboBox will revert to the first one.
Your bound columns needs to be unique to avoid this problem.
Perhaps if you describe what your trying to actually accomplish in more
detail. I see no reason (yet) why these Combos even have four columns. It
sounds like you want to make selections in (up to four) combos to find a
record. In that case, each Combo only needs the one column you want to
select and can be limited to unique choices for that column rather then
including duplicates that are only broken by other columns.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
.
- Prev by Date: Re: Where to get the royalty-free runtime for Access 2003?
- Next by Date: Re: display pathname of linked mdb
- Previous by thread: Linked Table Manager and Access 97
- Next by thread: Re: How to with a combo box (to Rick and Steve)
- Index(es):
Relevant Pages
|
Loading