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

Multiple Choice selection boxes

Status
Not open for further replies.

mikelt

Programmer
Jul 4, 2000
14
GB
When you first go into the Simply Query Wizard you are presented with a screen showing all the available fields in a list box&nbsp;&nbsp;(left hand side) and an empty list box ( right hand side) ready to receive the selected fields.<br><br>Buttons in between the to list boxes provide the mechanism to move and item from the left hand list nox to the right hand list bos and vice versa.<br><br>Does anyone have any idea how you go about creating a form like this or what programming is involved.<br><br>Any response would be gratefully received as I don't really know where to start.<br><br>Thanks in anticipation<br><br>Mikelt<br>
 
You would put two list boxes on your form, lstLeft and lstRight, with the buttons in between.&nbsp;&nbsp;Call the buttons, cmdRLOne (move one from Right to Left), cmdRLAll, cmdLROne, and cmdLRAll.<br><br>I don't know what you want to have in your list box, but let's assume that you have the items you want in the left list box.<br><br>You would want to put code in the cmdLRone Click event to delete the item that is selected from lstLeft and put it in lstRight.&nbsp;&nbsp;In the Click event of cmdLRAll you want to step through all items, and delete each from the lstLeft and put in lstRight.&nbsp;&nbsp;Similar functionality is needed to move items from lstRight to lstLeft.<br><br>I can't get much more detailed on the actual code until I know what the source of the data in the list boxes is.<br><br>Hope the above helps.&nbsp;&nbsp;I'll be glad to help with the actual code, if you post a bit more detail<br><br> <p>Kathryn<br><a href=mailto: > </a><br><a href= > </a><br>
 
Thank you Kathryn, I understand what you are getting at but how do you delete an item in the left list box and add the item to the right list box?<br><br>The scenario is a order item line product code where the customer can select say any 3 items from a list of 10 items. So in an order entry form the operator will select a product from a product file which relates to a multiple choice of any 3 item from a list of 10 stock items.<br>A select query of a table will be 'select stock_item from multipack where product_code = me![product_code]. This will then result in a list of 10 stock items to populate the left hand list box and the operator then has to select any 3 items from the list of 10 stock items.<br>From the left hand list box of 10 items, selected via the select query,&nbsp;&nbsp;what should the record source for the right hand list box be? An array or another table?<br><br>I hope the above explains the scenario that I am trying to achieve and look forward to your reply.<br><br>Many Thanks<br><br>Mike Thorpe (mikelt)<br>&nbsp;<br>
 
Sorry for the delay in answering; I only work Tuesdays - Fridays.<br><br>For your purposes, to keep things simple, do you really need to delete the item from the left list of ten items?&nbsp;&nbsp;You can write some pretty easy code to make sure that an item isn't sent over twice.<br><br><br>To give you an idea of the code to make data selected in the left box to appear in the right box, try this in the click event of the button which moves items from the left to the right list<br><br>***Begin Code***<br><br>Private Sub cmdLROne_Click()<br>lstRight.RowSource = lstRight.RowSource & lstLeft & &quot;;&quot;<br>End Sub<br><br><br>***End Code***<br><br>If you want the operator to just click on the item in the list and move it to the right box use<br><br>***Begin Code***<br><br>Private Sub lstLeft_Click()<br>lstRight.RowSource = lstRight.RowSource & lstLeft & &quot;;&quot;<br>End Sub<br><br>***End Code***<br><br>This code will have to be modified if you want to make the left hand box a multi-select box.&nbsp;&nbsp;This would allow the operater to select all three items in the left box and move them to the right box all at once.<br><br>Hope this helps.&nbsp;&nbsp;Let me know if you need more help.<br><br> <p>Kathryn<br><a href=mailto: > </a><br><a href= > </a><br>
 
Sorry for butting in, but another way to do this is to have a table for each listbox, plus one to store the starting info.&nbsp;&nbsp;Start&nbsp;&nbsp;by appending the data from the table with the starting info to the table used as the source for the left listbox, leaving the table for the right listbox empty. Add code behind the buttons to add and delete from the appropriate tables for the item selected in the listbox.<br><br>if you'd like I have a sample database base that uses two list boxes to set up a sort order for a report, its about 340kb. I'll e-mail it to you if you like.<br><br><br>PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top