Need technique for coordinating two listboxes

B

Bob Howard

Hi!

I need a technique for coordinating lists in two listboxes. The box on the
left contains a list of people's names. The first column is hidden and is
the record key of the name table. The box on the right will contain a list
of names of those people who have been selected from the box on the left.
The first column is hidden and is the record key. I use a double-click to
select a name (from the left) or de-select a name (from the right).

There are two tables involved. The primary table contains the total list of
names (it's behind the query for the left-hand listbox). The second table
contains a list of those items that have been selected. All I have in this
table are two fields --- a primary key (autonumber ensure unique records)
and a second field which is the record number of the item selected from the
left-hand (primary) table.

I have the program working to the extent that when I double-click a name in
the left-hand listbox, it appears in the right-hand listbox (which gets
requeried to keep the list in alphabetic order). And when I double-click a
name in the right-hand listbox it gets removed from that box.

But what I want to do next is modify the query behind the left-hand listbox
so that the names of those people already selected (and in the right-hand
listbox) don't appear ... they are no longer "eligible".

I already have code to prevent duplicate entries on the right, but I think a
better approach is to not have those people already selected and on the
right to appear on the left. This is somewhat like various programs and how
they handle setting up their tools and Icons on the top of the window ---
the list of available tools/icons is on the left, and the list of the chosen
ones is on the right. Once an item is chosen, it no longer appears on the
left.

Any pointers to a technique for this?

Bob (@Martureo.Org)
 
A

Allen Browne

Create a new query, using the Unmatched wizard. It will help you select the
entries from the main People table that are not in the other table. You can
then use this as the RowSource for your left-hand list box.

After your code adds the entry to the right-table, requery the left one,
i.e.:
Me.[MyList1].Requery
 
B

Bob Howard

Thanks Allen --- I'll check it out.

My code already requeries the box on the left in anticipation of a great
answer such as yours!!!!!

Bob.


Allen Browne said:
Create a new query, using the Unmatched wizard. It will help you select the
entries from the main People table that are not in the other table. You can
then use this as the RowSource for your left-hand list box.

After your code adds the entry to the right-table, requery the left one,
i.e.:
Me.[MyList1].Requery

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob Howard said:
Hi!

I need a technique for coordinating lists in two listboxes. The box on
the
left contains a list of people's names. The first column is hidden and is
the record key of the name table. The box on the right will contain a
list
of names of those people who have been selected from the box on the left.
The first column is hidden and is the record key. I use a double-click to
select a name (from the left) or de-select a name (from the right).

There are two tables involved. The primary table contains the total list
of
names (it's behind the query for the left-hand listbox). The second table
contains a list of those items that have been selected. All I have in
this
table are two fields --- a primary key (autonumber ensure unique records)
and a second field which is the record number of the item selected from
the
left-hand (primary) table.

I have the program working to the extent that when I double-click a name
in
the left-hand listbox, it appears in the right-hand listbox (which gets
requeried to keep the list in alphabetic order). And when I double-click
a
name in the right-hand listbox it gets removed from that box.

But what I want to do next is modify the query behind the left-hand
listbox
so that the names of those people already selected (and in the right-hand
listbox) don't appear ... they are no longer "eligible".

I already have code to prevent duplicate entries on the right, but I think
a
better approach is to not have those people already selected and on the
right to appear on the left. This is somewhat like various programs and
how
they handle setting up their tools and Icons on the top of the window ---
the list of available tools/icons is on the left, and the list of the
chosen
ones is on the right. Once an item is chosen, it no longer appears on the
left.

Any pointers to a technique for this?

Bob (@Martureo.Org)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top