control not working

A

angie

i have a unbound control box in my report and i want it to show values from a
multi select text box of my form. with combos for example it would be
something like [forms]![myformname]![comboname]. i cannot get this to work
with the multiselect textbox. is there a way i could achieve that?
 
D

Duane Hookom

You need code to retrieve the selected items in a multi-select list box. Here
is a simple function that returns the items.
Public Function GetItems(ctlListBox As ListBox, _
Optional strDelimiter As String = ", ") As String
Dim strOutPut As String
Dim item
For Each item In ctlListBox.ItemsSelected
strOutPut = strOutPut & ctlListBox.ItemData(item) & strDelimiter
Next
If Len(strOutPut) > Len(strDelimiter) Then
GetItems = Left(strOutPut, Len(strOutPut) - Len(strDelimiter))
Else
GetItems = ""
End If
End Function
 
A

angie

where do i place the code? in which part of my unbound text box?


Ο χÏήστης "Duane Hookom" έγγÏαψε:
You need code to retrieve the selected items in a multi-select list box. Here
is a simple function that returns the items.
Public Function GetItems(ctlListBox As ListBox, _
Optional strDelimiter As String = ", ") As String
Dim strOutPut As String
Dim item
For Each item In ctlListBox.ItemsSelected
strOutPut = strOutPut & ctlListBox.ItemData(item) & strDelimiter
Next
If Len(strOutPut) > Len(strDelimiter) Then
GetItems = Left(strOutPut, Len(strOutPut) - Len(strDelimiter))
Else
GetItems = ""
End If
End Function
--
Duane Hookom
Microsoft Access MVP


angie said:
i have a unbound control box in my report and i want it to show values from a
multi select text box of my form. with combos for example it would be
something like [forms]![myformname]![comboname]. i cannot get this to work
with the multiselect textbox. is there a way i could achieve that?
 
D

Duane Hookom

You can place the code in a new module and save the module with the name
"modControlCode". Then try add a text box with a control source of:
=GetItems([forms]![myformname]![multi select text box])
--
Duane Hookom
Microsoft Access MVP


angie said:
where do i place the code? in which part of my unbound text box?


Ο χÏήστης "Duane Hookom" έγγÏαψε:
You need code to retrieve the selected items in a multi-select list box. Here
is a simple function that returns the items.
Public Function GetItems(ctlListBox As ListBox, _
Optional strDelimiter As String = ", ") As String
Dim strOutPut As String
Dim item
For Each item In ctlListBox.ItemsSelected
strOutPut = strOutPut & ctlListBox.ItemData(item) & strDelimiter
Next
If Len(strOutPut) > Len(strDelimiter) Then
GetItems = Left(strOutPut, Len(strOutPut) - Len(strDelimiter))
Else
GetItems = ""
End If
End Function
--
Duane Hookom
Microsoft Access MVP


angie said:
i have a unbound control box in my report and i want it to show values from a
multi select text box of my form. with combos for example it would be
something like [forms]![myformname]![comboname]. i cannot get this to work
with the multiselect textbox. is there a way i could achieve that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top