I have a subform that shows a pivot graph of the records tied to the main form. That form has two listbox's used to filter those records. I have that tied to a button to pull new form to review individual records that were filtered. I would like to update the subform to show the pivot graph of the filtered results. They would like it to update as selections made, but would settle for a button to click to update the graph. The code below is in the EventClick of the button but error that the for isn't named.
Here is the function
Code:
Dim stdocname As String
Dim strwhere As String
stdocname = "[form]![frm_main]![sfrm_chart]"
strwhere = "1=1 "
strwhere = strwhere & ListSelections(Me.WorkByCommodity, "[category]", "'")
strwhere = strwhere & ListSelections(Me.workbyLocation, "[Location]", "'")
DoCmd.OpenForm stdocname, , , strwhere, acEdit, acNormal
Here is the function
Code:
Function ListSelections(lboListBox As ListBox, _
strFieldName As String, _
strDelim As String) As String
' Used to grab the selected items form the listbox selections to use in the where statement
'send in a list box control object
Dim strIn As String
Dim varItem As Variant
If lboListBox.ItemsSelected.Count > 0 Then
strIn = " AND " & strFieldName & " In ("
For Each varItem In lboListBox.ItemsSelected
strIn = strIn & strDelim & lboListBox.ItemData(varItem) & strDelim & ", "
Next
'remove the last ", " and add the ")"
strIn = Left(strIn, Len(strIn) - 2) & ") "
End If
ListSelections = strIn
End Function