Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filter in Reports (Access 2000)

    In the OnOpen event of a report I have the following filter :
    Me![FilterOn] = True
    Me.Filter = " customerid= " & 4

    i want to imporve my code and to include not only Customer

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Filter in Reports (Access 2000)

    You could use something like this:

    <pre>Private Sub Report_Open(Cancel As Integer)

    Me.Filter = "[CustomerID] In (1,7,17,52,53)"
    Me.FilterOn = True

    End Sub
    </pre>

    This assumes the CustomerID number is an actual number and not text. If CustomerID is text data type then the filter values should be delimited by single quotes:
    <pre>"[CustomerID] In ('1','7','17','52','53')" </pre>

    In either case the "Me.Filter" should precede the "Me.FilterOn" statement. If the values you are filtering on can change in number or value, recommend using an array variable to populate the "IN" statement.
    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •