473,800 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2463
mc****@gaf.com (Melissa Cowan) wrote in message news:<25******* *************** ****@posting.go ogle.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********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ****@posting.go ogle.com>...
mc****@gaf.com (Melissa Cowan) wrote in message news:<25******* *************** ****@posting.go ogle.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.Lis tCount
Counting = 0
Set db1 = CurrentDb()
Set rs1 = db1.OpenRecords et("MultiSelect Action")

With rs1
While Counting < ItemCount
.AddNew
![CPAR_ID] = txtCPAR_ID.Valu e
![Employee] = lstSelected.Col umn(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********@hot mail.com (Pieter Linden) wrote in message
news:<bf****** *************** *****@posting.g oogle.com>...
mc****@gaf.com (Melissa Cowan) wrote in message

news:<25****** *************** *****@posting.g oogle.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
1973
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 code: #include <iostream> #include <malloc.h> #include <iomanip> using namespace std;
7
1902
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 :-) By the way, please don't reply just to tell me that my code isn't optimized and that I should use a delimited database rather than a line by line record. If I had my way, I'd do it differently too.
0
2182
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 am able to check using xpath in asp.net 2.0 till MenuItem node. if i check visible attribute value till SubMenuLevel0 node then in tree it will not display the MenuItem Node at all Note: My tree Menu will start from MenuItem node and it will...
4
10622
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 and a function pointer. This function pointer will be a void* function in other objects that will use the scheduler. So when another object calls the addSchedule function the scheduler will run these tasks at each interval provided. There may...
4
17882
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 problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
22
4073
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
2534
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 =============================== <script language="JavaScript">
2
1916
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 and I'll leave my code in here ========================================================= package chapfour; /** * * @author Deezle */ import java.awt.*;
0
1537
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 {$}. How can i get rid of that? from Tkinter import * class MyApp: def __init__(self, parent): self.myparent = parent
0
1515
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 demonstrates the problem. Anyway, this demonstrates what you are getting (independent of python version): import Tkinter
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10269
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
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
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.