How can I make this filter work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DAHMB
    New Member
    • Nov 2007
    • 147

    How can I make this filter work

    I have a command buttton on a form that calls a report and filters the report as follows:

    Code:
    Private Sub btnLetter_Click()
    Dim strSQL As String
    Dim stLetter As String
    Dim stFilter As String
    
        DoCmd.Close
        
        stLetter = "rptParkingLetter"
        DoCmd.OpenReport stLetter, acViewPreview
        stFilter = ("Letter2Sent Is Null And InDispute = No And Closed = No")
    
    'Build SQL String
        strSQL = strSQL & stFilter & " And "
     
        If strSQL <> "" Then
        'Strip Last " And "
            strSQL = Left(strSQL, (Len(strSQL) - 5))
            'Set the Filter property
            Reports!rptParkingLetter.Filter = strSQL
            Reports!rptParkingLetter.FilterOn = True
        End If
    End Sub
    My problem is line 10 I don't know how to show No as "No" so the report will see it as a value.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    What type of fields are [InDispute] and [Closed] Dan?

    Comment

    • DAHMB
      New Member
      • Nov 2007
      • 147

      #3
      they are text fields.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        In that case you simply want (For further info see Quotes (') and Double-Quotes (") - Where and When to use them) :
        Code:
        stFilter = ("Letter2Sent Is Null And InDispute = 'No' And Closed = 'No'")

        Comment

        • DAHMB
          New Member
          • Nov 2007
          • 147

          #5
          Thank you! and thanks for the explanation link.
          Dan

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32662

            #6
            No worries Dan. You can guess we've had similar questions before ;)

            Comment

            Working...