Listbox Add Method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Am I in error or what?
There seems to be no Add Method for a listbox control.
Should I change my controls to ComboBoxes?
My problem is:
I have a form with two listboxes and two command buttons to transfer items
from the first list to the second (and eventually back to the first one).
The first list is bound to a table with 14 entries. The second list in
unbound and will eventually contain the items from the first list that need
to have some calculations done for.
I tried to write this code but it does not work:
' *****************************
Me.lst2nd.Add ("Test")
Me.lst2nd.Add (Me.lst1st.Selected)
Me.lst1st.RemoveItem (Me.lst1st.Selected)
' *****************************
What's wrong with that code?
 
There's no Add method for listboxes in Visual Basic either: it's AddItem.

IIRC, the only versions of Access that allow the AddItem method are Access
2002 and 2003.
 
Hi Douglas,
I realized that but I do not see this method either in the list (AddItem).
It is not available and when I type it, I get an error: "Method or member not
found."
' *****************************
Me.lstTest.AddItem ("Test")
' *****************************
It is the same for the method RemoveItem. I cannot use it. I know that those
methods are not available for listboxes that have a Table or query as their
Origin source. So I specified Value list. It didn't change anything. I closed
Access and restarted it. Nothing better.
I changed the reference Microsoft ActiveX Data Objects Library from 2.1 to
2.8 and that changed nothing again. I still cannot find those methods in the
properties list. So I cannot use them.
What else can I do?
The only method available to me is AddColon.
Thanks for your help.
 
Hi again Doug,
I had not seen the rest of your comment concerning Access 2002 and 2003. I
work with 2000, so I can't use those methods unless we upgrade.

Thank you for your comment, and sorry for the first reply that you should
forget.
 
Thank you for your comment, and sorry for the first reply that you
should forget.

It's easy enough to manipulate the RowSource string:

strOldRowSource = "red;yellow;blue"

strNewRowSource = strOldRowSource & ";test"

With me.listbox
.RowSource strNewRowSource
.Requery

End With


If you can use Split and Join functions, then it's even easier.


Hope that helps


Tim F
 
Hi Tim,
What you explain is another way to solve the problem, but I had to turn
around on a dime and found another solution that is equivalent and even
easier to program. Now, I use only one listbox with multiselect activated.
That way, the user can choose his items and press the OK button to start the
process.
I will remember your comment for the next time.
Thank you
 
Back
Top