473,394 Members | 1,878 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,394 software developers and data experts.

List Boxes - Storing Multiple values in a table

2
Ok...

I have a list box (called "lstbox" & unbound) that is populated by a table (tblsports). I need to be able to select multiple sports and then store it in a table called tblmaster (in column 24 the field is called "sports").

I know when you set the list box to simple or extended it returns a null value. I need this to return a string obivously. For example, if you like Tennis, Golf, and Hockey you can select it all and then store it in "sports" field of tblmaster

I have been looking at a bunch of tutorials and its been awhile since programming in college (C++ and VB).

Thanks in advance!
Jan 2 '07 #1
4 4395
ADezii
8,834 Expert 8TB
Ok...

I have a list box (called "lstbox" & unbound) that is populated by a table (tblsports). I need to be able to select multiple sports and then store it in a table called tblmaster (in column 24 the field is called "sports").

I know when you set the list box to simple or extended it returns a null value. I need this to return a string obivously. For example, if you like Tennis, Golf, and Hockey you can select it all and then store it in "sports" field of tblmaster

I have been looking at a bunch of tutorials and its been awhile since programming in college (C++ and VB).

Thanks in advance!
Multiple values should never be stored in a single Field but if you insist:
This Test code was placed on a Command Button on a Form, multiple values
were selected from the List Box [lstBox] and this code was executed in the
Button's Click() Event - it works fine.

1) Populate the List Box in whatever fashion you so desire
2) Set the Multi Select property of the List Box to Extended
3) Select 1 or more values from the List Box
4) Click on a Command Button, place the code in the AfterUpdate() Event of
the List Box, or wherever you like - its placement is irrelevant
5) A Comma Delimited list of selected Sports will be written to a "Hidden"
Text Box called txtSports which is bound to an appropriate Field in the Table

Expand|Select|Wrap|Line Numbers
  1. Dim varItem As Variant, ctl As Control, strSports As String
  2. Set ctl = Me![lstBox]
  3. If ctl.ItemsSelected.Count > 0 Then
  4.   For Each varItem In ctl.ItemsSelected
  5.     strSports = strSports & ctl.ItemData(varItem) & ","
  6.   Next
  7.  
  8.   Me![txtSports] = Left$(strSports, Len(strSports) - 1)
  9. Else
End If
Jan 2 '07 #2
cas122
2
Thank You so Much!!
Jan 3 '07 #3
ADezii
8,834 Expert 8TB
Thank You so Much!!
The pleasure was all mine
Jan 4 '07 #4
This is not making a lot of sense . Can you please elaborate. how to you use the command button. It does not have an after update event?
Jul 31 '19 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Usenet | last post by:
Hi there, I am quite a novice to MS Access, and I would deeply appreciate help on the following: I have created a list box in a form. I wish for that list box to enter multiple values from table...
4
by: Onion | last post by:
This has to be simple, but I'm forced to admit that I'm a novice who can't figure it out. I have a listbox in a form that allows multiple selections. That works fine. The problem: I can't...
3
by: syounger | last post by:
Hi. I have a report in Access 2000 that is based on selection made from a series of interdependent list boxes. The boxes I have right now are Source, Table, Column, Date. The user chooses Source...
1
by: David | last post by:
Hi, I have a field which holds the Product IDs of related products in a format of: 1#5#4#7 Where the numbers are the Related Product IDs. I am trying to create a form to manage this info.
22
by: guitarromantic | last post by:
Hey everyone, I run a site with staff-submitted reviews, and most of them are written by one author. However, we also do "multiple" reviews. Up until now I just had a userid for a 'Multiple'...
3
by: pedro8ae | last post by:
Hi guys, I know that I can select more than one option using a list box by changing tha multi select option to simple or extended BUT, How do I have to design my field on my table? I have tried to...
6
by: Col | last post by:
Hi - I've never worked with list boxes before. Here's what I'd like to do - have a list box (or some other control) that allows multiple selection and stores all the values in one field (can be...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.