Listbox to Listbox (Value List) (1 Viewer)

JPaulo

Developer
Local time
Today, 14:04
Joined
Dec 21, 2009
Messages
185
Hi all;

I have the ListBox1 and ListBox2
The ListBox1 has Value list= "A" "B", "C"
How do I insert an item selected ListBox1 in the Value list of ListBox2
and delete item the ListBox1 ?

Access 2003 or Access 2007
 

JPaulo

Developer
Local time
Today, 14:04
Joined
Dec 21, 2009
Messages
185
Thanks ;

Code it works, but does not save the Value list.


I have this code and it works, but equal, does not save the Value list when I close the form.


Private Sub moveBetweenLists(lstBoxFrom As Access.ListBox, lstBoxTo As Access.ListBox)
On Error GoTo err_list
Dim counter As Integer
Dim colCounter As Integer
Dim varListItem As Variant
Dim indexArray() As Variant
Dim listValue As String
Dim intCountSelected As Integer
ReDim indexArray(0 To lstBoxFrom.ListCount)
For Each varListItem In lstBoxFrom.ItemsSelected
For colCounter = 0 To lstBoxFrom.ColumnCount - 1
listValue = listValue & """" & CStr(Nz(lstBoxFrom.Column(colCounter, varListItem), " ")) & """;"
Next colCounter
listValue = Left(listValue, Len(listValue) - 1)
lstBoxTo.AddItem (listValue)
indexArray(counter) = varListItem
counter = counter + 1
listValue = ""
Next varListItem
intCountSelected = lstBoxFrom.ItemsSelected.Count
For counter = 0 To intCountSelected - 1
lstBoxFrom.RemoveItem (indexArray(counter) - counter)
Next counter
Exit_Sub:
Exit Sub
err_list:
MsgBox Err.Description
Resume Exit_Sub
Exit Sub
End Sub


Private Sub Lista1_DblClick(Cancel As Integer)
Call moveBetweenLists(List1, List2)
End Sub


Any idea ?
 

rainman89

I cant find the any key..
Local time
Today, 10:04
Joined
Feb 12, 2007
Messages
3,016
Where are the listboxes getting their original values from?

EDIT: Forget that. I see its a value list

So you want to save the value list after you move it and keep it there?

Read option 4

http://allenbrowne.com/ser-27.html
 

JPaulo

Developer
Local time
Today, 14:04
Joined
Dec 21, 2009
Messages
185
Try demo please;
 

Attachments

  • testing_listbox.zip
    10.4 KB · Views: 134

rainman89

I cant find the any key..
Local time
Today, 10:04
Joined
Feb 12, 2007
Messages
3,016
Take a look at my previous post..

Under option 4, as Allen says. You are essentially changing the design of the form.

Are you sure you want to do that?

If you are using 2007 you can turn on value list edits, but you will be prompted to save the design of the form every time you change it.
 

Users who are viewing this thread

Top Bottom