Link to home
Start Free TrialLog in
Avatar of Stapman
Stapman

asked on

ListBox lines

How do I add a line to my listbox? When I use rowsource the line is written over the existing line instead of adding a new line.

Thanks
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

lst1.AddItem "HELLO"

or am I missing the point ??
Avatar of Stapman
Stapman

ASKER

I know the question seems stupid but AddItem doesn't work!

My source:
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Data")
   
If Rs.RecordCount > 0 Then  
 Rs.MoveFirst
 For Each Element In list_2.ItemsSelected
   Rs.index = "Age"
   Rs.Seek "=", Integervariable
   list1.AddItem = Rs!Name
 Next Element
End If

list1.AddItem doesn't work (method / object not found)
I don't know if you just typed it wronly, but it should read

list1.additem rs!name (i.e. without the equals sign)

If that isn't the problem, try setting a string var to rs!name first..

fred=rs!name
list1.additem fred

then if the error is on the fred=... line, the field 'name' might be missing or something...
Avatar of Stapman

ASKER

None of your suggestions solve my problem. I think the problem lies in the fact that "additem" is a not known method to my object. Resulting in the idea that my object isn't a "standard" listbox or I changed some properties of the listbox which result in this problem.

When you type "list1." you get a list of methods you can use and "additem" is not part of that list. Any idea what's wrong?
Avatar of Éric Moreau
I think that you use a DBListBox instead of a ListBox control.

You can't mix lines from the database and manually added lines. What you have to do is to completely populate your list. So you retrieve a recordset than add it lines to your listbox (with the AddItem method).
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stapman

ASKER

The method "Clear" doesn't exist with "my" listbox (nor does AddItem).

Furthermore I have an empty ListBox and selected "value list" in the properties of the ListBox.

How Do I create a ListBox - how do I create a DBListBox? Is the property "value list" / "table" the difference between the two?
When you click on the 'listbox' on the screen and go to properties, what does it say at the top of the properties page ??

something like

lstmylist ListBox ??


Avatar of Stapman

ASKER

Something like:

ListBox: Name

*I have a german version of Access
Access ???? I thought you were using VB  !!!

aggghhrrrrr !!
Avatar of Stapman

ASKER

The method "Clear" doesn't exist with "my" listbox (nor does AddItem).

Furthermore I have an empty ListBox and selected "value list" in the properties of the ListBox.

How Do I create a ListBox - how do I create a DBListBox? Is the property "value list" / "table" the difference between the two?
sigh. Have customer service pull this Q and then repost it over in the Database/Access area. This is the VB/Database area and the programs are completely different.

M

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics since many new ones were recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange