473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.add Item 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 11754
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.n et> wrote in message
news:3q******** ***********@new s4.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.add Item 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.n et> wrote in message
news:3q******** ***********@new s4.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.add Item 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.n et> wrote in message news:<3q******* ************@ne ws4.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.add Item 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*****@localho st.net (Larry Linson) wrote in
<3m************ *******@nwrddc0 3.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*****@localho st.not (Larry Linson) wrote in
<hs************ *******@nwrddc0 1.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
3075
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 has any advices?? #include <iostream> using namespace std;
10
15108
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 *enemydata; // Holds information about an enemy (in a game) // Its a double linked list node
24
5724
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 macros */ #ifndef PUBLIC #define PUBLIC
4
3590
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; };   struct pcb *pcb_pointer;
3
2698
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> #include<stdlib.h> int main(void) {
0
1812
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 each node in the list must contain two pointers, one pointing forward and one pointing backwards. Each node in the list will contain 3 data values:...
10
6554
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
8613
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 anything from a short integer value to a complex struct type, also has a pointer to the next node in the single-linked list. That pointer will be NULL...
12
4011
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 the shared memory. I run fedora 9 and gcc 4.2. I am able to insert values in to the list, remove values from the list, but the problem is in...
7
5757
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 compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template...
0
7707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.