Hi
I have a form with a few textboxes and some listboxes with multiple values allowed. I would like to use an append query to insert everything into a table but for some reason it just gives me no values at all for the listboxes (the textboxes are ok). Is there something that could be done.
Thanks in advance
4 2921 MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi
I have a form with a few textboxes and some listboxes with multiple values allowed. I would like to use an append query to insert everything into a table but for some reason it just gives me no values at all for the listboxes (the textboxes are ok). Is there something that could be done.
Thanks in advance
To retrieve values from a multiselect listbox: -
Dim valSelect As Variant
-
Dim strValue As String ' just used for the demonstration
-
-
For Each valSelect In Me.listboxName.ItemsSelected
-
strValue = strValue & ", '" & Me.listboxName.ItemData(valSelect) & "'"
-
Next valSelect
-
-
' to remove last comma
-
strValue = Left(strValue, Len(strValue)-2)
-
Mary
NeoPa 32,579
Recognized Expert Moderator MVP
To retrieve values from a multiselect listbox: -
Dim valSelect As Variant
-
Dim strValue As String ' just used for the demonstration
-
-
For Each valSelect In Me.listboxName.ItemsSelected
-
strValue = strValue & ", '" & Me.listboxName.ItemData(valSelect) & "'"
-
Next valSelect
-
-
' to remove last comma
-
strValue = Left(strValue, Len(strValue)-2)
-
Mary
There's a small bug with this in that there are two common ways of stripping off the extra ',' and this mixes the two. It adds the extra comma at the front but strips it from the rear. I prefer the front way (oo er) because the code to strip it is shorter, but both ways work. - Dim valSelect As Variant
-
Dim strValue As String ' just used for the demonstration
-
-
For Each valSelect In Me.listboxName.ItemsSelected
-
strValue = strValue & ", '" & Me.listboxName.ItemData(valSelect) & "'"
-
Next valSelect
-
-
' to remove leading comma
-
strValue = Mid(strValue, 3)
MMcCarthy 14,534
Recognized Expert Moderator MVP
There's a small bug with this in that there are two common ways of stripping off the extra ',' and this mixes the two. It adds the extra comma at the front but strips it from the rear. I prefer the front way (oo er) because the code to strip it is shorter, but both ways work. - Dim valSelect As Variant
-
Dim strValue As String ' just used for the demonstration
-
-
For Each valSelect In Me.listboxName.ItemsSelected
-
strValue = strValue & ", '" & Me.listboxName.ItemData(valSelect) & "'"
-
Next valSelect
-
-
' to remove leading comma
-
strValue = Mid(strValue, 3)
Sorry that was my error, meant to place the comma at the end not the front. Good catch Ade.
MMcCarthy 14,534
Recognized Expert Moderator MVP
Revised code doing it my way ... -
Dim valSelect As Variant
-
Dim strValue As String ' just used for the demonstration
-
-
For Each valSelect In Me.listboxName.ItemsSelected
-
strValue = strValue & "'" & Me.listboxName.ItemData(valSelect) & "', "
-
Next valSelect
-
-
' to remove leading comma
-
strValue = Left(strValue, Len(strValue)-2)
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: steve |
last post by:
Hello, I am using ACCESS 2000 and am currently trying to make a
database for a police department and they have several types of
license classes. i.e A,B,C,D,E etc.
What they have asked for is a drop down box with all the types listed
and simple the ability to click on multiple check boxes to show what
class(es) of license the person has. I have read through most of the
articles on multiple list boxes but this is not my need. I dont need...
|
by: DC Gringo |
last post by:
I have two listboxes, the first of which is an autopostback=true that allows
multiple row selection. When I select multiple values (by holding down CTL)
in the first one, it should query the second one. I seem unable to do this
as it only sends back the first item I select whether I have the CTL key
down or not. Upon the return trip, I can select another one, but it still
only sends value for the last one I selected.
-- MY LISTBOX --...
|
by: Ned Balzer |
last post by:
Hi,
Can anyone tell me what is the best approach for passing multiple keys
from a listbox to a SQL update? I prefer to use stored procedures for
updates. I am using asp.net 2.0 and SQL 2000, soon to upgrade to SQL
2005.
I can envision several ways to do it, such as passing a delimited set
of keys in a string to the sp, which then parses through them and maybe
puts them into a temp table and performs the update. or is there maybe
|
by: Jay Ruyle |
last post by:
I'm trying to figure out a way to list several items in a listbox and let
the user select any number of items in the listbox. I have tried to code in
the items as bitwise items but all it stores in the database is the top item
in the listbox.
How can I get the listbox to add all the bit values to be stored and also
come out properly when viewed later?
Example:
|
by: EricLondaits |
last post by:
Hi,
I have an ASP.NET page with a ListBox that is data bound to a table
with a single field (it holds a list of valid IDs). The page also has
a textBox into which you can add new valid IDs, one per line (this is
in order to make the process of adding new IDs easy, since it's only
done at time of configuration).
I have no problem with retrieving the contents of the textBox,
splitting it into a string array, validating the individual...
| |
by: Pippen |
last post by:
Hi,
I'm trying to read all the selected items in a ListBox. So after the user
selects the values they want in the ListBox they select a button. This is
where I want to put into a string all the values that were selected. The
ListBox is populated by a stored proc that reads a DB table. Yes, I have the
SelectionMode property set to MultiExtended, I have also tried MultiSimple.
I have seen some examples for ASP Web forms but I'm using...
|
by: billa856 |
last post by:
Hi,
My Project is in MS Access.
In that I have one form in which I have some textboxes,comboboxes and listboxes.
Now when I select value from 1st combobox(CustomerID) then it wil generate list for 1st listbox(PalletNo).
Now I want to select miltiple values from that 1st listbox(PalletNo).
and based upon this selection from 1st listbox(PalletNo) and combobox(CustomerID) I want to generate list for 2nd listbox(PONo).
For example
...
|
by: 6afraidbecause789 |
last post by:
Hi - Has anyone ever used toggle buttons to select items in a
listbox? I'd like to put about 24 toggle buttons on an unbound form
that select or deselect items in a multiple select listbox. I've come
across a way to set the listbox value to only 1 at a time, but need
multiple toggle buttons to be on their corresponding listbox item
values to be selected. Thanks!
|
by: AccessIdiot |
last post by:
Apologies if this has been answered before - I searched but couldn't find anything.
I have a listbox that is populated with a query. I need to enable the user to select multiple items (simply set listbox Multi Select property to Simple yes?) and then I'd like to commit the choices to a single text field in a table, concatenated and separated by commas.
So in other words if the listbox has these values:
BRN
CM
XD
RG
|
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,...
|
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...
| |
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |