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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|