473,396 Members | 1,914 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.

Help with multi-select listbox

I am using Access 2000. I have the Developer's handbook and got the
code for the mulit select listbox from there. It sends the selected
value to another listbox, lstselected. What I need to do is loop
through there and add each item to a table. I can add the other info
fromt he form to a table, just not the otems in the listbox. It only
shows as 0. I tried using the varItem and it told me that the action
is not supported. I'm a bit rusty in my Access programming so any help
is appreciated. Thanks.

Melissa Cowan
Nov 13 '05 #1
5 2445
mc****@gaf.com (Melissa Cowan) wrote in message news:<25**************************@posting.google. com>...
I am using Access 2000. I have the Developer's handbook and got the
code for the mulit select listbox from there. It sends the selected
value to another listbox, lstselected. What I need to do is loop
through there and add each item to a table. I can add the other info
fromt he form to a table, just not the otems in the listbox. It only
shows as 0. I tried using the varItem and it told me that the action
is not supported. I'm a bit rusty in my Access programming so any help
is appreciated. Thanks.

Melissa Cowan


there's code at mvps.org for looping through the selecteditems
collection of a listbox. Then you'd just open a recordset based on
the table and then use the .Add method to add a new record, .Edit it,
then .Update it once you've made all your additions. Nothing doing.
Should all be under "Recordset" in the help.
Nov 13 '05 #2
Hmm, well, I've looked there and can't find anything that works. I've
found an article on passing values from a mulit-select box to a query
but nothing about how to loop through itmes in a listbox and add it to
a table. I just really need info on how to go through the items in a
listbox. I've got the code to add the records to a table and that part
works. It just won't pick up each name in the SelectedItems box and
add it. I'm assuming I need to loop through each name in that box as
the names get sent over to it from the listbox with all the Employee
names in it. Am I correct? Thinking wrong? Trying to be too complex on
my form?

Melissa
pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>...
mc****@gaf.com (Melissa Cowan) wrote in message news:<25**************************@posting.google. com>...
I am using Access 2000. I have the Developer's handbook and got the
code for the mulit select listbox from there. It sends the selected
value to another listbox, lstselected. What I need to do is loop
through there and add each item to a table. I can add the other info
fromt he form to a table, just not the otems in the listbox. It only
shows as 0. I tried using the varItem and it told me that the action
is not supported. I'm a bit rusty in my Access programming so any help
is appreciated. Thanks.

Melissa Cowan


there's code at mvps.org for looping through the selecteditems
collection of a listbox. Then you'd just open a recordset based on
the table and then use the .Add method to add a new record, .Edit it,
then .Update it once you've made all your additions. Nothing doing.
Should all be under "Recordset" in the help.

Nov 13 '05 #3
Ok, I solved my own problem. I used the listcount and then loop
through the listbox while a number I'm incrementing is less than that.
Here is the code for what I did. If anyone has any better suggestions
than that I am always open to them.

Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim ItemCount As Long
Dim Counting As Long

ItemCount = lstSelected.ListCount
Counting = 0
Set db1 = CurrentDb()
Set rs1 = db1.OpenRecordset("MultiSelectAction")

With rs1
While Counting < ItemCount
.AddNew
![CPAR_ID] = txtCPAR_ID.Value
![Employee] = lstSelected.Column(0, Counting)
![ActionNumber] = ActionID.Value
.Update
Counting = Counting + 1
Wend
End With
Thanks.
Melissa Cowan
Nov 13 '05 #4
Here's what I use:

For Each i In Me![lstbox].ItemsSelected
blah = blah & Me![lstbox].ItemData(i)
Next i

HTH

Jan

Hmm, well, I've looked there and can't find anything that works. I've
found an article on passing values from a mulit-select box to a query
but nothing about how to loop through itmes in a listbox and add it to
a table. I just really need info on how to go through the items in a
listbox. I've got the code to add the records to a table and that part
works. It just won't pick up each name in the SelectedItems box and
add it. I'm assuming I need to loop through each name in that box as
the names get sent over to it from the listbox with all the Employee
names in it. Am I correct? Thinking wrong? Trying to be too complex on
my form?

Melissa
pi********@hotmail.com (Pieter Linden) wrote in message
news:<bf**************************@posting.google .com>...
mc****@gaf.com (Melissa Cowan) wrote in message

news:<25**************************@posting.google .com>...
> I am using Access 2000. I have the Developer's handbook and got the
> code for the mulit select listbox from there. It sends the selected
> value to another listbox, lstselected. What I need to do is loop
> through there and add each item to a table. I can add the other info
> fromt he form to a table, just not the otems in the listbox. It only
> shows as 0. I tried using the varItem and it told me that the action
> is not supported. I'm a bit rusty in my Access programming so any help
> is appreciated. Thanks.
>
> Melissa Cowan


there's code at mvps.org for looping through the selecteditems
collection of a listbox. Then you'd just open a recordset based on
the table and then use the .Add method to add a new record, .Edit it,
then .Update it once you've made all your additions. Nothing doing.
Should all be under "Recordset" in the help.


Jan Stempel
Stempel Consulting
Nov 13 '05 #5
Forgot to add, you have to dim the i as integer (or, I seem to have done it as
variant in my last use; not sure why).

Jan
Jan Stempel
Stempel Consulting
Nov 13 '05 #6

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

Similar topics

1
by: Silver | last post by:
Hi everyone, my program compiles and executes, but I get an error during run-time. I guess it has something to do with memory allocation (which I don't seem to fully control yet).. Here's the...
7
by: Shane | last post by:
Hi, Thanks in advance for the help. I have been to many websites and tried several solutions to my problem, but have fixed part of it. It's time to come humbly to the newsgroups for help :-) ...
0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
4
by: keepyourstupidspam | last post by:
Anyone know of a reliable design for a Windows C++ Task Scheduler Class. The scheduler will expose a member function that will add schedules, its parameters will be an interval to run the tasks...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
5
by: Olly | last post by:
Hello Everyone! Could someone please have a look at my JS Form I posted below....Something wrong there, but I don't understand what's exactly. Many thanks. Olly ...
2
by: deezle | last post by:
Hello, I am trying to get my calculator GUI to +,-,* and /. I have got all of them to work except my division. I was wondering if someone could helpme figure out the problem. Any input would help...
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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.