If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Can you move highlighted data from one listbox to another listbox on the same form?
I am bringing back data from a table in a listbox and want to move the
selected records into a blank listbox (or possibly textbox). Is there an easy way to do this? I also was looking for an arrow button ( ) to trigger this data move but have been unsuccessful in my attempt to locate it. Thanks for any help... Matt |
#2
|
|||
|
|||
I am bringing back data from a table in a listbox and want to move the
selected records into a blank listbox (or possibly textbox). Is there an easy way to do this? I also was looking for an arrow button ( ) to trigger this data move but have been unsuccessful in my attempt to locate it. I made a form with two list boxes, lstOne and lstTwo. lstOne was list-bound to a table and set for Multi Select. I set the RowSourceType property of lstTwo to Value List. Then I made a button, cmdMove and gave it as a caption. Access has some arrow icons that are much nicer. Then I did this (the Requery at the bottom may not be needed): Private Sub cmdMove_Click() Dim s As String Dim i As Integer For i = 1 To lstOne.ItemsSelected.count s = lstOne.ItemData(i) lstTwo.RowSource = lstTwo.RowSource & ";" & s Next lstTwo.Requery End Sub What this procedure does is copy items from one list box to the next. If you want to MOVE items, then inside the For Next loop, you would need to Currentdb.Execute a delete statement on the bout list box, and then requery that one too. -- Peace & happy computing, Mike Labosh, MCSD Feed the children! Save the whales! Free the mallocs! |
#3
|
|||
|
|||
Thanks Mike!
"Mike Labosh" wrote in message ... I am bringing back data from a table in a listbox and want to move the selected records into a blank listbox (or possibly textbox). Is there an easy way to do this? I also was looking for an arrow button ( ) to trigger this data move but have been unsuccessful in my attempt to locate it. I made a form with two list boxes, lstOne and lstTwo. lstOne was list-bound to a table and set for Multi Select. I set the RowSourceType property of lstTwo to Value List. Then I made a button, cmdMove and gave it as a caption. Access has some arrow icons that are much nicer. Then I did this (the Requery at the bottom may not be needed): Private Sub cmdMove_Click() Dim s As String Dim i As Integer For i = 1 To lstOne.ItemsSelected.count s = lstOne.ItemData(i) lstTwo.RowSource = lstTwo.RowSource & ";" & s Next lstTwo.Requery End Sub What this procedure does is copy items from one list box to the next. If you want to MOVE items, then inside the For Next loop, you would need to Currentdb.Execute a delete statement on the bout list box, and then requery that one too. -- Peace & happy computing, Mike Labosh, MCSD Feed the children! Save the whales! Free the mallocs! |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel: How can I move data from a form into subsequent rows in a. | NNIGuy | Worksheet Functions | 2 | September 6th, 2004 05:47 PM |
Copying data from contact form to another | musicman | Contacts | 1 | September 2nd, 2004 02:19 PM |
Display Parameter from Form on Report | sara | Setting Up & Running Reports | 10 | July 19th, 2004 04:54 PM |
Data not saving in the continous form | wesbird | Using Forms | 0 | July 6th, 2004 07:51 PM |
Linking Excel data through Access to use a Form as an Interface | Laura | Links and Linking | 0 | March 23rd, 2004 03:59 PM |