I have a report with a series of combo boxes on it, then i have one list box. I want that one to, on the report, only display those values that are selected. (checked).
Thanks,
Jeremiah
I have a report with a series of combo boxes on it, then i have one list box. I want that one to, on the report, only display those values that are selected. (checked).
Thanks,
Jeremiah
I wouldn't display a listbox on a report....but a label with the selected values from the list box. I would add code to the report similar to this:
Private Sub Report_Open(Cancel As Integer)
Me.lblArgs.Caption = listB
End Sub
Private Function listB() As String
Dim strList As String ' Where condition
Dim lst As ListBox ' multiselect list box
Dim vItem As Variant ' items in listbox
Dim iLen As Integer ' length of string.
Set lst = Forms![TopEmployers]!lstSource
'loop through all items in listbox
For Each vItem In lst.ItemsSelected
If Not IsNull(vItem) Then
strList = strList & lst.ItemData(vItem) & ";"
End If
Next
listB = strList
End Function
Where would you go about adding code to the report? I've added code to various items in access, but never to a report.
Add it to the on open event of the report. You'll find it on the property sheet.
Okay, i still couldn't get it to work. I did figure out where to put the code, and the code does attempt to run at start up, but it doesn't work. It comes up with a debug error on the set lst = command.
I've set the command to Set lst = Forms!Machine_Orders![I- Special Option]
Which is the Form, and the specific list box i am trying to access.
Any ideas?
Nevermind! I'm a moron lol. I forgot, you can't call the form if you dont have it open! With the form open this works fine. I did change one thing, i changed from ";" to vbcrlf to cause it to insert a new line and drop the multiple selections down to a line each item. Now it works great! Thanks for your help!