J
Julie B
Good morning! My problem is complicated to explain, I will try to be as clear
as possible.
I have a report containing a main section + 2 sub reports. The total of 3
sections all have different filters in the report filter. In a form, I have a
multi-select drop down to choose the desired departments to include in the
report.
When running the report, it looks like the multi-select works, but my
filters are not applied.
The following code is the "on click" event for a button to run the report :
On Error GoTo Err_cmdStrategic_Click
Dim varItem As Variant 'Selected items in lstApplication
Dim strWhere As String 'String to use as WhereCondition for
lstApplication
Dim strDescrip As String 'Description of WhereCondition for
lstApplication
Dim lngLen As Long 'Length of string for lstApplication
Dim strDelim As String 'Delimiter for this field type for
lstApplication.
Dim stDocName As String 'Name of 1st report to open.
stDocName = "MonthlyStrategic"
'Loop through the ItemsSelected in the Application list box.
With Me.lstApplication
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets for
lstApplication
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[ApplicationID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Application: " & Left$(strDescrip, lngLen)
End If
End If
DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=strWhere
Exit_cmdStrategic_Click:
Exit Sub
Err_cmdStrategic_Click:
MsgBox Err.Description
Resume Exit_cmdStrategic_Click
Any ideas why the filters are not respected ??
Thanks so much for all replies !
Julie
as possible.
I have a report containing a main section + 2 sub reports. The total of 3
sections all have different filters in the report filter. In a form, I have a
multi-select drop down to choose the desired departments to include in the
report.
When running the report, it looks like the multi-select works, but my
filters are not applied.
The following code is the "on click" event for a button to run the report :
On Error GoTo Err_cmdStrategic_Click
Dim varItem As Variant 'Selected items in lstApplication
Dim strWhere As String 'String to use as WhereCondition for
lstApplication
Dim strDescrip As String 'Description of WhereCondition for
lstApplication
Dim lngLen As Long 'Length of string for lstApplication
Dim strDelim As String 'Delimiter for this field type for
lstApplication.
Dim stDocName As String 'Name of 1st report to open.
stDocName = "MonthlyStrategic"
'Loop through the ItemsSelected in the Application list box.
With Me.lstApplication
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets for
lstApplication
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[ApplicationID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Application: " & Left$(strDescrip, lngLen)
End If
End If
DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=strWhere
Exit_cmdStrategic_Click:
Exit Sub
Err_cmdStrategic_Click:
MsgBox Err.Description
Resume Exit_cmdStrategic_Click
Any ideas why the filters are not respected ??
Thanks so much for all replies !
Julie