control not working

  • Thread starter Thread starter angie
  • Start date Start date
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?
 
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
 
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?
 
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?
 
Back
Top