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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listboxes - best approach

Status
Not open for further replies.

andzejek

MIS
Sep 1, 2007
154
US
Can someone tell me what is the best way to do two listboxes where from one listbox user will select records to the second listbox.
 
You'll need to be more specific to what you want done. But in general, you'd want to have two tables, one for the source from which listbox-1 will be populated, then on the dbl-click (or through a button between the two listboxes, like the 'add' and 'remove' buttons you see on many to/from listboxes) you run the sql to insert data into the table that is the source of the second listbox, and refresh the box.

This assumes that the data is to be somewhat permanent, but like I said, you'll need to go deeper into detail on what you're trying to accomplish.
--Jim
 
I was not sure about tables thing... I tought I can do this based on recordsets or other some kind of temprorary data(records) container. I don't need to store records selected/moved/copied to second listbox.
Andrew
 
You can then set the list source type to 'value list' and use the .additem method and the .removeitem method to clear.
--Jim
 
faq702-6326

This is all encapsulated, and works on older versions of Acess that do not have the add/remove item method that I told you about. Lots of functionality and requires little coding.

Another way is to add a boolean field in the table "isSelected". The first list is based on "isSelected" equal false, the second list is based on true. When you select a value from either list it changes false to true and true to false. Requery the lists after update.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top