Need help with data mismatch

bstboy

Registered User.
Local time
Today, 05:23
Joined
Sep 14, 2011
Messages
23
This is code to run a filter on a report using two multi-select list boxes. It was working fine before, and then I changed the [FY] or fiscal year data in all associated tables from text to number, and now it won't work. The debug stop on the highlighted line, not sure what that means.

Let me preface this by saying I know very little about code and I received help to put this together.

Code:
Private Sub cmdApplyFilter_Click()
    Dim varItem As Variant
    Dim strYear As String
    Dim strBrand As String
    Dim strFilter As String
' Check that the report is open
    If SysCmd(acSysCmdGetObjectState, acReport, "Inventory$Crosstab v4") <> acObjStateOpen Then
        MsgBox "You must open the report first."
        Exit Sub
    End If
' Build criteria string from lstYear listbox
    For Each varItem In Me.lstYear.ItemsSelected
        strYear = strYear & ",'" & Me.lstYear.ItemData(varItem) _
        & "'"
    Next varItem
    If Len(strYear) = 0 Then
        strYear = "Like '*'"
    Else
        strYear = Right(strYear, Len(strYear) - 1)
        strYear = "IN(" & strYear & ")"
    End If

' Build criteria string from lstBrand listbox
    For Each varItem In Me.lstBrand.ItemsSelected
        strBrand = strBrand & ",'" & Me.lstBrand.ItemData(varItem) _
        & "'"
    Next varItem
    If Len(strBrand) = 0 Then
        strBrand = "Like '*'"
    Else
        strBrand = Right(strBrand, Len(strBrand) - 1)
        strBrand = "IN(" & strBrand & ")"
    End If

' Build filter string
    strFilter = " [Brand] " & strBrand & _
                " AND [FY] " & strYear
' Apply the filter and switch it on
    With Reports![Inventory$Crosstab v4]
        .Filter = strFilter
  [COLOR=Red][B]      .FilterOn = True[/B][/COLOR]
    End With
End Sub

Private Sub cmdRemoveFilter_Click()
    On Error Resume Next
' Switch the filter off
    Reports![Inventory$Crosstab v4].FilterOn = False
End Sub
Thanks for any help
 
Last edited:
Nevermind, I had text wraps when I needed number wraps on the Year criteria.
 

Users who are viewing this thread

Back
Top Bottom