473,396 Members | 2,102 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,396 software developers and data experts.

List Box

Hi

I want to add an item (string) to a list box that is already on the form in
the form_open procedure, but it wont work. Can't I just type
me.listname.addItem item:= "blabla" to add a single string to the list? Or
do I have to do something more with the list box?

--
Vegard
Nov 12 '05 #1
6 11733
Try in a different event; as the Controls may not be initialized during
Open... use the Load event, as a first try.

Also, AddItem only works on List and Combo Boxes which have the ValueList
option selected, not those bound to a RowSource.

Larry Linson
Microsoft Access MVP

"Vegard H. Villmones" <vv******@c2i.net> wrote in message
news:3q*******************@news4.e.nsc.no...
Hi

I want to add an item (string) to a list box that is already on the form in the form_open procedure, but it wont work. Can't I just type
me.listname.addItem item:= "blabla" to add a single string to the list? Or
do I have to do something more with the list box?

--
Vegard

Nov 12 '05 #2
The last thing to occur when a form opens is the controls populate the form so
there is no form event that will allow you to add something to a listbox on the
form. To achieve what you want you need to add the item to the source of the
data for the listbox before you open the form. You can do this by creating a
recordset of the source and then use the Add/Update method of the recordset.
This can all be done in one procedure:

Create Recordset
Add/Update item to recordset
Open the Form

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com
"Vegard H. Villmones" <vv******@c2i.net> wrote in message
news:3q*******************@news4.e.nsc.no...
Hi

I want to add an item (string) to a list box that is already on the form in
the form_open procedure, but it wont work. Can't I just type
me.listname.addItem item:= "blabla" to add a single string to the list? Or
do I have to do something more with the list box?

--
Vegard

Nov 12 '05 #3
"Vegard H. Villmones" <vv******@c2i.net> wrote in message news:<3q*******************@news4.e.nsc.no>...
Hi

I want to add an item (string) to a list box that is already on the form in
the form_open procedure, but it wont work. Can't I just type
me.listname.addItem item:= "blabla" to add a single string to the list? Or
do I have to do something more with the list box?


If you want to do that, you have to append it to the rowsource and
then requery. you're thinking in VB, not VBA. (I know... doesn't
make sense, but that's the way listboxes work in Access...

Pieter
Nov 12 '05 #4
Access 2002 and 2003 both have an AddItem method for ListBoxes populated
from a ValueList, Pieter. There's also been a method for filling a List or
Combo box from a callback function since at least Access 2.0.


Nov 12 '05 #5
bo*****@localhost.net (Larry Linson) wrote in
<3m*******************@nwrddc03.gnilink.net>:
Also, AddItem only works on List and Combo Boxes which have the
ValueList option selected, not those bound to a RowSource.


And .AddItem did not exist until A2K3, no?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #6
bo*****@localhost.not (Larry Linson) wrote in
<hs*******************@nwrddc01.gnilink.net>:
Access 2002 and 2003 both have an AddItem method for ListBoxes
populated from a ValueList, Pieter. There's also been a method for
filling a List or Combo box from a callback function since at
least Access 2.0.


But I think Pieter's point was that in a database application, it
makes more sense to populate a listbox with a SQL string than with
a list, as you would in a VB app, where you most often don't have a
database to draw the list items from.

That said, of course we all sometimes need listboxes that aren't
populated via SQL.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesnąt matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
0
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and...
10
by: AZRebelCowgirl73 | last post by:
This is what I have so far: My program! import java.util.*; import java.lang.*; import java.io.*; import ch06.lists.*; public class UIandDB {
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
12
by: kalyan | last post by:
Hi, I am using Linux + SysV Shared memory (sorry, but my question is all about offset + pointers and not about linux/IPC) and hence use offset's instead on pointers to store the linked list in...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.