I have a main form that filters information and then displays that information in the details. I am trying to take that displayed information and put it in a report so it is nice and neat and then put a graph that sums the memberstargeted and membersconverted based on criteria that I will attach with my database. The graph works great alone when clicking the button from the mainform to go to the graph. It does what it should, however when I try and do anything with the report, it wants me to re-enter the parameters. Then when I just bypass all of that by clicking ok and placing nothing in there, I can view the report with embedded graph, and the report is showing what it did from mainform but graph is not updated. The goal is to just go from the mainform to the subreport/with subform graph by clicking the button on the mainform. I am pasting my code and my zipped DB
Code:
Option Compare Database
Option Explicit
Private Sub cmdReport_Click()
DoCmd.OpenForm "graph", acFormPivotChart, , GetFilterFromListBoxes
DoCmd.OpenReport "search_programs", acViewPreview, , GetFilterFromListBoxes
End Sub
Private Sub cmdReset_Click()
Dim ctrl As Access.Control
Dim itm As Variant
For Each ctrl In Me.Controls
If ctrl.ControlType = acListBox Then
If ctrl.MultiSelect = 0 Then
ctrl = Null
Else
For Each itm In ctrl.ItemsSelected
ctrl.Selected(itm) = False
Next
End If
End If
Next ctrl
Me.Filter = ""
Me.FilterOn = False
End Sub
Private Sub cmdResults_Click()
Dim formfilter As String
formfilter = GetFilterFromListBoxes
Debug.Print formfilter
Me.FilterOn = False
Me.Filter = formfilter
Me.FilterOn = True
End Sub
Public Function GetFilterFromListBoxes() As String
Dim lst As Access.ListBox
Dim ctrl As Access.Control
Dim fieldName As String
Dim fieldType As String
Dim TotalFilter As String
Dim ListFilter As String
Dim itm As Variant
'Each listbox needs a tag property with the field name and the field type
'Seperate these with a ;
'The types are Text, Numeric, or Date
For Each ctrl In Me.Controls
If ctrl.ControlType = acListBox Then
fieldName = Split(ctrl.tag, ";")(0)
fieldType = Split(ctrl.tag, ";")(1)
For Each itm In ctrl.ItemsSelected
If ListFilter = "" Then
ListFilter = GetProperType(ctrl.ItemData(itm), fieldType)
Else
ListFilter = ListFilter & "," & GetProperType(ctrl.ItemData(itm), fieldType)
End If
Next itm
If Not ListFilter = "" Then
ListFilter = fieldName & " IN (" & ListFilter & ")"
End If
If TotalFilter = "" And ListFilter <> "" Then
TotalFilter = ListFilter
ElseIf TotalFilter <> "" And ListFilter <> "" Then
TotalFilter = TotalFilter & " AND " & ListFilter
End If
ListFilter = ""
End If
Next ctrl
GetFilterFromListBoxes = TotalFilter
End Function
Public Function GetProperType(varItem As Variant, fieldType As String) As Variant
If fieldType = "Text" Then
GetProperType = sqlTxt(varItem)
ElseIf fieldType = "Date" Then
GetProperType = SQLDate(varItem)
Else
GetProperType = varItem
End If
End Function
Public Function sqlTxt(varItem As Variant) As Variant
If Not IsNull(varItem) Then
varItem = Replace(varItem, "'", "''")
sqlTxt = "'" & varItem & "'"
End If
End Function
Function SQLDate(varDate As Variant) As Variant
If IsDate(varDate) Then
If DateValue(varDate) = varDate Then
SQLDate = Format$(varDate, "\#mm\/dd\/yyyy\#")
Else
SQLDate = Format$(varDate, "\#mm\/dd\/yyyy hh\:nn\:ss\#")
End If
End If
End Function
Any help would be fantastic cuz I have been going insane trying to figure this out.