"2 columns" Selection interface

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I don't know what it is called, but we as users often see this graphical
interface
in which 2 columns are presented...
The left column list the items (usually fields) available for user to select.
The right column serves as a container that holds items selected by the user.
Controls (>, >>, <, <<) are usually provided to enable user to move items
between the two columns.
Now I suppose reader will get the picture by now what I am talking about.
The question is: how may I implement an object like that?
Is the code for this object available as a module from somewhere that I may
use?
---
Moving along, I tried to implement this idea using 2 list boxes (for the
left & right columns).
And I ran into a weird problem - of not being able to copy value from the
left list into the right list.
Here is the main line of my code:
.....
ctl2.ItemData(0) = ctl1.Column(0, ctl1.ItemsSelected(0))
.....
The trouble with the above, as I read from the help file, is that the
ItemData property of a List Box is a read only property. (And yet I was
trying to assign or write to it.)
Is my interpretation of "help" correct?
If so, isn't it a little weird that one cannot change the value of a list
box item using code?
I would apprecieate any comments on this.
Thanks.
David
 
Hi David.

Yes, you can use a pair of list boxes and 4 command buttons, but the core
issue here is, Where is the data supposed to finish up?

Normally you will want a related table to hold the data. For example if this
is a client and the mailing lists they are on, you will have a table with
fields:
ClientID foreign key to tblClient.ClientID
ListID foreign key to tblList.ListID
and you add a new record for each combination.

If that is the idea, the first list box (the one where there is a match)
will have a RowSource will be a query that gets the data that lists that do
match. The 2nd list box will have a RowSource that gets the data that does
not match - you can use the Unmatched Query Wizard to create that.

Now the code to move from the first listbox (has) to the 2nd listbox (has
not) will execute a Delete query statement to remove the entry from the
table. The code to move the other direction (from "has not" to "has") will
execute an Append query statement to add the record to the table. Likewise
Remove All is a delete query, and Add All is an append query.

After executing the queries, just Requery the list boxes to make them show
correctly.

If the list boxes are multi-select, you will need to loop through the
ItemsSelected to get all the items to add/delete.

Hope that's clear enough, and on target for what you need to do.
 
Exactly what you want is described in Chapter 7 of Litwin et al.'
excellent "Access 2002 Desktop Developers' Handbook" (ISBN
0-7821-4009-2), and a Class to implement it comes on the companion
disk. The Class doesn't do things quite the way I would, but it will
give you an excellent start. The book should (IMHO) be on any Access
Developer's bookshelf (actually, it spends more time on my desk!).

Hello,
I don't know what it is called, but we as users often see this graphical
interface
in which 2 columns are presented...
The left column list the items (usually fields) available for user to select.
The right column serves as a container that holds items selected by the user.
Controls (>, >>, <, <<) are usually provided to enable user to move items
between the two columns.
Now I suppose reader will get the picture by now what I am talking about.
The question is: how may I implement an object like that?
Is the code for this object available as a module from somewhere that I may
use?
---
Moving along, I tried to implement this idea using 2 list boxes (for the
left & right columns).
And I ran into a weird problem - of not being able to copy value from the
left list into the right list.
Here is the main line of my code:
.....
ctl2.ItemData(0) = ctl1.Column(0, ctl1.ItemsSelected(0))
.....
The trouble with the above, as I read from the help file, is that the
ItemData property of a List Box is a read only property. (And yet I was
trying to assign or write to it.)
Is my interpretation of "help" correct?
If so, isn't it a little weird that one cannot change the value of a list
box item using code?
I would apprecieate any comments on this.
Thanks.
David


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Thanks. I got the idea.

Allen Browne said:
Hi David.

Yes, you can use a pair of list boxes and 4 command buttons, but the core
issue here is, Where is the data supposed to finish up?

Normally you will want a related table to hold the data. For example if this
is a client and the mailing lists they are on, you will have a table with
fields:
ClientID foreign key to tblClient.ClientID
ListID foreign key to tblList.ListID
and you add a new record for each combination.

If that is the idea, the first list box (the one where there is a match)
will have a RowSource will be a query that gets the data that lists that do
match. The 2nd list box will have a RowSource that gets the data that does
not match - you can use the Unmatched Query Wizard to create that.

Now the code to move from the first listbox (has) to the 2nd listbox (has
not) will execute a Delete query statement to remove the entry from the
table. The code to move the other direction (from "has not" to "has") will
execute an Append query statement to add the record to the table. Likewise
Remove All is a delete query, and Add All is an append query.

After executing the queries, just Requery the list boxes to make them show
correctly.

If the list boxes are multi-select, you will need to loop through the
ItemsSelected to get all the items to add/delete.

Hope that's clear enough, and on target for what you need to do.
 
Thanks for the book suggestion.
It happens to be in the set I just acquired, but haven't begun reading yet.
 
Back
Top