A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Can you move highlighted data from one listbox to another listbox on the same form?



 
 
Thread Tools Display Modes
  #1  
Old September 24th, 2004, 04:16 PM
Col. Forbin
external usenet poster
 
Posts: n/a
Default 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  
Old September 24th, 2004, 07:42 PM
Mike Labosh
external usenet poster
 
Posts: n/a
Default

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  
Old September 24th, 2004, 07:51 PM
Col. Forbin
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 07:46 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.