A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multi-Select LIst Box Not Appearing in Text Box



 
 
Thread Tools Display Modes
  #1  
Old May 6th, 2008, 05:31 PM posted to microsoft.public.access.forms
Pattyt
external usenet poster
 
Posts: 6
Default Multi-Select LIst Box Not Appearing in Text Box

tHello,
I have a multi-select list box in which the selection should be stored in a
bound text field on my main form. My problem is that when I select multiple
items from my list box the selections don't appear in the text box. If I go
back to the list box properties and assign a "none" to multi select property
and I then select one item from the list box, my selection appears in the
text box.

Can anyone figure out what I am doing wrong?
  #2  
Old May 6th, 2008, 06:21 PM posted to microsoft.public.access.forms
Golfinray
external usenet poster
 
Posts: 1,597
Default Multi-Select LIst Box Not Appearing in Text Box

2 great explainations of that: Check Martin Green at www.fontstuff.com and
Allen Browne at www.allenbrowne.com

"Pattyt" wrote:

tHello,
I have a multi-select list box in which the selection should be stored in a
bound text field on my main form. My problem is that when I select multiple
items from my list box the selections don't appear in the text box. If I go
back to the list box properties and assign a "none" to multi select property
and I then select one item from the list box, my selection appears in the
text box.

Can anyone figure out what I am doing wrong?

  #3  
Old May 6th, 2008, 06:50 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Multi-Select LIst Box Not Appearing in Text Box

On Tue, 6 May 2008 09:31:02 -0700, Pattyt wrote:

tHello,
I have a multi-select list box in which the selection should be stored in a
bound text field on my main form. My problem is that when I select multiple
items from my list box the selections don't appear in the text box. If I go
back to the list box properties and assign a "none" to multi select property
and I then select one item from the list box, my selection appears in the
text box.

Can anyone figure out what I am doing wrong?


You need code to extract the selected values from a multi-select list
box. You don't need code if the list box is not multi-select.

You can code the list box's Exit event....
Private Sub ListBoxName_Exit(Cancel As Integer)
' read the selected values

On Error GoTo Err_Handler
Dim strValue As String
Dim varItem As Variant
For Each varItem In Me.ListBoxName.ItemsSelected
strValue = strValue & Me.ListBoxName.ItemData(varItem) & ", "
Next varItem
strValue = Left(strValue, Len(strValue) - 2)
Me.ControlName = strValue

'Then clear the items from the list box
For Each varItem In Me.ListBoxName.ItemsSelected
ListBoxName.Selected(varItem) = False
Next varItem

Exit_Sub:
Exit Sub
Err_Handler:
If Err = 5 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub

End Sub

this will display in a Form's control like this ....
Red, Blue, Green, Orange

However, STORING more than one value in a field is NOT a good idea.
The usual method of storing more than one value in a field for a
record is to use a sub-table bound to the main table by an ID field.
Then you can store as many values as you like as individual records in
the sub-table that are bound to a record in the main table.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #4  
Old May 6th, 2008, 06:50 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Multi-Select LIst Box Not Appearing in Text Box

The code for retrieving data from a multi-select listbox is different from
that for retrieving data from a single select listbox. Here's a snippet of
code from Mary McCarthy over at bytes.com that should do the job:

http://www.thescripts.com/forum/show...65#post2316465

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200805/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.