Multiple Filtering on a subform

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    #1

    Multiple Filtering on a subform

    I have your typically form/subform. You enter the account number in a
    textbox and select whether you want to see the detail or summary
    information on the main form. Both fields I want to filter on are
    text. Here is a sample of the code I am using.

    The filtering works fine when I do them independently (see below)
    Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = "[EKCNBR]
    =" & Me![bxAcctNbr]

    Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter =
    "[BREAKLVL] =" & "'" & 2 & "'"

    When I combine them, I receive the error message "You canceled the
    previous operation" when it hits the filterOn = true line.
    strfilter = "[EKCNBR] = """ & Me![bxAcctNbr] & """" & " And " &
    "[BREAKLVL] = "" & 2 & """
    Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
    Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True

    Can anyone figure this out? Thanks for any help you can provide
  • Allen Browne

    #2
    Re: Multiple Filtering on a subform

    strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
    ""2"")"
    Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
    Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True



    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Doug" <doug.corey@cox .com> wrote in message
    news:1ebb60c8.0 404281923.62b06 db1@posting.goo gle.com...[color=blue]
    > I have your typically form/subform. You enter the account number in a
    > textbox and select whether you want to see the detail or summary
    > information on the main form. Both fields I want to filter on are
    > text. Here is a sample of the code I am using.
    >
    > The filtering works fine when I do them independently (see below)
    > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = "[EKCNBR]
    > =" & Me![bxAcctNbr]
    >
    > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter =
    > "[BREAKLVL] =" & "'" & 2 & "'"
    >
    > When I combine them, I receive the error message "You canceled the
    > previous operation" when it hits the filterOn = true line.
    > strfilter = "[EKCNBR] = """ & Me![bxAcctNbr] & """" & " And " &
    > "[BREAKLVL] = "" & 2 & """
    > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
    > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True
    >
    > Can anyone figure this out? Thanks for any help you can provide[/color]


    Comment

    • Doug

      #3
      Re: Multiple Filtering on a subform

      I am still getting the error message "You canceled the previous
      operation". Is there another way to process this request?

      Thanks for your help

      "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message news:<40909bc1$ 0$16585$5a62ac2 2@freenews.iine t.net.au>...[color=blue]
      > strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
      > ""2"")"
      > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
      > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True
      >
      >
      >
      > --
      > Allen Browne - Microsoft MVP. Perth, Western Australia.
      > Tips for Access users - http://allenbrowne.com/tips.html
      > Reply to group, rather than allenbrowne at mvps dot org.
      >
      > "Doug" <doug.corey@cox .com> wrote in message
      > news:1ebb60c8.0 404281923.62b06 db1@posting.goo gle.com...[color=green]
      > > I have your typically form/subform. You enter the account number in a
      > > textbox and select whether you want to see the detail or summary
      > > information on the main form. Both fields I want to filter on are
      > > text. Here is a sample of the code I am using.
      > >
      > > The filtering works fine when I do them independently (see below)
      > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = "[EKCNBR]
      > > =" & Me![bxAcctNbr]
      > >
      > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter =
      > > "[BREAKLVL] =" & "'" & 2 & "'"
      > >
      > > When I combine them, I receive the error message "You canceled the
      > > previous operation" when it hits the filterOn = true line.
      > > strfilter = "[EKCNBR] = """ & Me![bxAcctNbr] & """" & " And " &
      > > "[BREAKLVL] = "" & 2 & """
      > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
      > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True
      > >
      > > Can anyone figure this out? Thanks for any help you can provide[/color][/color]

      Comment

      • Allen Browne

        #4
        Re: Multiple Filtering on a subform

        The message indicates that there is something wrong with the filter string.
        Perhaps there is a spelling mistake, or perhaps the delimiters are wrong.

        For example, if CKCNBR is a Number type field (not a Text type field), drop
        the extra quotes:
        strfilter = "([EKCNBR] = " & Me![bxAcctNbr] & ") And ...

        One way to see how this should look would be to make a query into this
        table. Put any old number as an example under the 2 fields. Then switch to
        SQL view (View menu), and see what the WHERE clause looks like. At least you
        know what strfilter should end up like.

        Now add this to your code:
        Debug.Print strFilter
        After it messes up, open the Immediate Window (Ctl+G) and compare what it
        wrote to what you saw in the query.

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia.
        Tips for Access users - http://allenbrowne.com/tips.html
        Reply to group, rather than allenbrowne at mvps dot org.

        "Doug" <doug.corey@cox .com> wrote in message
        news:1ebb60c8.0 404290722.53a33 90c@posting.goo gle.com...[color=blue]
        > I am still getting the error message "You canceled the previous
        > operation". Is there another way to process this request?
        >
        > Thanks for your help
        >
        > "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message[/color]
        news:<40909bc1$ 0$16585$5a62ac2 2@freenews.iine t.net.au>...[color=blue][color=green]
        > > strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
        > > ""2"")"
        > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
        > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True
        > >
        > > "Doug" <doug.corey@cox .com> wrote in message
        > > news:1ebb60c8.0 404281923.62b06 db1@posting.goo gle.com...[color=darkred]
        > > > I have your typically form/subform. You enter the account number in a
        > > > textbox and select whether you want to see the detail or summary
        > > > information on the main form. Both fields I want to filter on are
        > > > text. Here is a sample of the code I am using.
        > > >
        > > > The filtering works fine when I do them independently (see below)
        > > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = "[EKCNBR]
        > > > =" & Me![bxAcctNbr]
        > > >
        > > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter =
        > > > "[BREAKLVL] =" & "'" & 2 & "'"
        > > >
        > > > When I combine them, I receive the error message "You canceled the
        > > > previous operation" when it hits the filterOn = true line.
        > > > strfilter = "[EKCNBR] = """ & Me![bxAcctNbr] & """" & " And " &
        > > > "[BREAKLVL] = "" & 2 & """
        > > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.Filter = strfilter
        > > > Forms![frmPaymentSearc h].[sbfrmPaymentSea rch].Form.FilterOn = True
        > > >
        > > > Can anyone figure this out? Thanks for any help you can provide[/color][/color][/color]


        Comment

        • Doug Corey

          #5
          Re: Multiple Filtering on a subform

          The did the trick!!!
          strfilter = "([EKCNBR] = " & Me![bxAcctNbr] & ") And ([BREAKLVL]
          =""2"")". The field EKCNBR contains numbers but based on the field data
          type it shows it as a text. I only assumed I should be looking for text
          rather than a number. The table is a linked table from the AS400 that I
          did not create. Thank you so very much!!!

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          Working...