Is there anyway to save multiple items selected in a list box to a string? Is it then possible to save the string to a record field in a table? Or is there another way to capture multiple items selected and stored them in a table? For example: I have a list box with the following items:
Listbox
cat
dog
rabbit
Table name = Animal_tbl
Animal Selected - this is a column heading and a text field.
6 10343 ADezii 8,834
Recognized Expert Expert
Is there anyway to save multiple items selected in a list box to a string?
Yes there is but: - What is your reason for storing multiple, selected Objects from a Multi-Select List Box to a Field in a Table?
- How do you wish the String to appear?
- cat,dog,rabbit
-
cat dog rabbit
-
cat-dog-rabbit
-
etc...
I'm trying to store multiple values in a field to reduce the amount of check boxes in a table. My present table has over 75 columns that are used to received check boxes from a form. But I need to capture each record/event from the user. So each record is unique and will be used in trending analysis. If there is another way that I can use to reduce the number of columns in a table then I will be open to that suggestion. Thank you and Happy New Year.
Sorry about not answering your last question. I was hoping to store the string with comas like in your first example above.
ADezii 8,834
Recognized Expert Expert
Assuming your List Box is named lstAnimals: - Dim ctl As ListBox
-
Dim varItm As Variant
-
Dim strBuild As String 'To build Animal Selected List
-
-
Set ctl = Me![lstAnimals]
-
-
If ctl.ItemsSelected.Count < 1 Then Exit Sub
-
-
For Each varItm In ctl.ItemsSelected
-
strBuild = strBuild & ctl.ItemData(varItm) & ","
-
Next varItm
-
-
strBuild = Left$(strBuild, Len(strBuild) - 1)
-
-
CurrentDb.Execute "INSERT INTO Animal_tbl ([Animal Selected]) VALUES " & _
-
"('" & strBuild & "')", dbFailOnError
Sample Results: - Animal Selected
-
Rabbit
-
Cat,Lion
-
Cat,Dog,Rabbit,Lion
-
Cat,Dog,Rabbit,Mouse,Lion
-
Dog
-
Dog,Rabbit,Mouse
Thank you for that. You should change your hobby (database programming) to the day job. But either way I'm glad you read my message.
ADezii 8,834
Recognized Expert Expert
Some things are fun as long as they are a hobby - once they become a job, then they are a burden! (LOL).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter Collinson |
last post by:
Hi...
Is there any way to style a List Item a different color and size than
the <LI> in an Ordered List?
I'd like a red super-script number and a dark blue text in a page's
footnotes. And...
|
by: Unknown User |
last post by:
How can I separate list items displayed inline by vertical bars | ?
If I use a background image that simulate a vertical bar, and I put this
bg image behind each list item, the last list item will...
|
by: deepakp |
last post by:
Hi,
I'm trying to create a site index page. The page layout will consist of
a header, left navigation and content display. The left navigation and
content display should look like the image file...
|
by: incredible |
last post by:
how to sort link list of string
|
by: RSH |
last post by:
Hi,
I have a situation where I need to add several "Hidden" properties to list
items in a dropdownlist. By default the DropDownList item has two
properties with regards to the listitems...
| |
by: John Dalberg |
last post by:
using VS 2005.
I have an unordered list with list items which are displayed horizontally.
Some of the list items have hyper links and some have checkboxes.
The problem is that the...
|
by: shapper |
last post by:
Hello,
How can I filter a List(Of String)?
I need to get the list elements which start with the letters contained
in the variable Text.
Thanks,
Miguel
|
by: Keith Hughitt |
last post by:
For example,
If you have a list:
<ul>
<li>item 1 is short.</li>
<li>item 2 is a little bit longer</li>
</ul>
regardless of the size of the contents of each list item, the element
|
by: c0mrade |
last post by:
I have a problem with getting the list items, below is my hibernate code, after that code there is my method ..and below that is my junit test. How can I make sure that query is executing properly,...
|
by: Frinavale |
last post by:
What I'd like to do is take a list and display it's items in a circle.
For example (the order of the in the circle doesn't matter..except for Item1, it has to be at the top):
Item1
...
|
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...
| |
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...
|
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: 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: 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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |