473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Filling listbox from VBA

Hi, I am using MS Access 2003 and I wish to simply fill a listbox from VBA. I have read that you can just do listname.additem .... but I do not have the .additem option after inputting the list name and was wondering why this is? I believe it may just be a reference/component thing but I've no idea really :-)

Thanks,
Gareth.
Oct 29 '07 #1
5 5010
ADezii
8,834 Expert 8TB
Hi, I am using MS Access 2003 and I wish to simply fill a listbox from VBA. I have read that you can just do listname.additem .... but I do not have the .additem option after inputting the list name and was wondering why this is? I believe it may just be a reference/component thing but I've no idea really :-)

Thanks,
Gareth.
You need no External References to use the AddItem Method in Access 2003, perhaps your syntax is incorrect. The correct usage is as follows, assuming your List Box is named List1:
Expand|Select|Wrap|Line Numbers
  1. Dim intCounter As Integer
  2.  
  3. 'critical step
  4. Me![List1].RowSourceType = "Value List"
  5.  
  6. For intCounter = 1 To 500
  7.   Me![List1].AddItem "Item Number: " & intCounter
  8. Next
  9.  
Sample List Box contents:
Expand|Select|Wrap|Line Numbers
  1. Item Number: 1
  2. Item Number: 2
  3. Item Number: 3
  4. Item Number: 4
  5. Item Number: 5
  6. Item Number: 6
  7. Item Number: 7
  8. Item Number: 8
  9. Item Number: 9
  10. Item Number: 10
  11. Item Number: 11
  12. Item Number: 12
  13. Item Number: 13
  14. Item Number: 14
  15. Item Number: 15
  16. Item Number: 16
  17. Item Number: 17
  18. Item Number: 18
  19. Item Number: 19
  20. Item Number: 20
  21. ...
  22. Item Number: 500
Oct 29 '07 #2
Hi, thanks for your reply.

I have just tried that and I don't get the .rowsourcetype thing appearing as an option either :-(

I can't understand why this is the case, any help is much appreciated.

Thanks.
Gareth.
Oct 29 '07 #3
ADezii
8,834 Expert 8TB
Hi, thanks for your reply.

I have just tried that and I don't get the .rowsourcetype thing appearing as an option either :-(

I can't understand why this is the case, any help is much appreciated.

Thanks.
Gareth.
In any Code Module Window, make sure the following Option is checked (Yes):
  1. In a Code Module Window
  2. Tools
  3. Options
  4. Editor
  5. Auto List Members (check)
  6. The Auto List Members Options controls whether or not the logical options for the completion of a Statement in VBA occurs.
  7. Good Luck and get back to me on this one.
Oct 29 '07 #4
Hi, thanks for your reply. I have managed to get what I needed, the reason the .additem wasn't available because it was on a report and apparently it is only available on forms etc but not reports.
Oct 30 '07 #5
ADezii
8,834 Expert 8TB
Hi, thanks for your reply. I have managed to get what I needed, the reason the .additem wasn't available because it was on a report and apparently it is only available on forms etc but not reports.
the reason the .additem wasn't available because it was on a report and apparently it is only available on forms etc but not reports.
You are correctamundo - you solved your own problem.
Oct 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JeffOfJerrsey | last post by:
Executing the following code: With ListBox1 .DisplayMember = "UserName" .ValueMember = "UserID" .DataSource = dtUsers End With With ddlUsers .DisplayMember = "UserName"
2
by: JMorrell | last post by:
I’m trying to populate a listbox with data that comes from my SQL server. I’ve created the connection, filled the dataset and loaded the data adapter. Apparently, I’m missing something...
2
by: Petter L | last post by:
I have set up a test program on how to use colletions saved and loaded from a file. It was a part of a other program until this happends. The saving process working fine but it looks like something...
1
by: lance2001 | last post by:
Hi, After viewing the entire Visual Basic 2005 Express Edition for Beginners video series, I have begun building a database driven application that will make use of listbox1 (multi-select)...
1
by: cj | last post by:
This used to work a year ago when I wrote it using SQL Express 2005 on my pc but I've created the database and tables on our production SQL Sever 2000 and it doesn't work What's listed in the...
5
by: markr1000 | last post by:
I must have looked searched in 500+ places that showed up in Google searchs, but not one has an example of what I want to do. I have a Listbox on a User Control because I want to control the...
7
by: Lebbsy | last post by:
I have searched the forum for this but found no match for my search. I would like to have a combo box that does not lookup values from a table but on selecting a value, the value is sent to a...
1
by: mlarsen1982 | last post by:
Hello, I have a quick question regarding filling a list box. Basically I need some assistance for a starting point. I have a form with 4 radio buttons for the user to select, then press next....
2
by: bplantes | last post by:
Hi All, I am new to Access programming and it has been a long time since I have done any programming at all, so I am a bit rusty. I am building a form in Access 2002 that displays a list of...
9
Vini171285
by: Vini171285 | last post by:
Hi, Actually i am filling a list box from database and depending on change in that list box ,the value corresponding to that selected index should come in the textbox,which should come from another...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.