Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ListBox lines

Posted on 1999-07-29
13
Medium Priority
?
297 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:Stapman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
13 Comments
 
LVL 10

Expert Comment

by:smegghead
ID: 1507243
lst1.AddItem "HELLO"

or am I missing the point ??
0
 

Author Comment

by:Stapman
ID: 1507244
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)
0
 
LVL 10

Expert Comment

by:smegghead
ID: 1507245
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...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Stapman
ID: 1507246
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?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 1507247
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).
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 200 total points
ID: 1507248
It should work. Here is a code snippet from a running program that does what you're saying. I'm using a ComboBox with the .Style set to 2, Dropdown List.

'
' Populate Interest Combo Box
'
sql = "select * from bmginb7_owner.listen_int where upper(li_active)='Y'"   'Only select active entries
Set rs = db.OpenRecordset(sql, dbOpenSnapshot, dbSQLPassThrough)
'
Interest.Clear
'
Do While Not rs.EOF
    Interest.AddItem Trim("" & rs!LI_DESC)
    Interest.ItemData(Interest.NewIndex) = Val("" & rs!LI_ID)
    rs.MoveNext
Loop

This works every time.

M

0
 

Author Comment

by:Stapman
ID: 1507249
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?
0
 
LVL 10

Expert Comment

by:smegghead
ID: 1507250
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 ??


0
 

Author Comment

by:Stapman
ID: 1507251
Something like:

ListBox: Name

*I have a german version of Access
0
 
LVL 10

Expert Comment

by:smegghead
ID: 1507252
Access ???? I thought you were using VB  !!!

aggghhrrrrr !!
0
 

Author Comment

by:Stapman
ID: 1507253
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?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1507254
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

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6822779
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.

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question