Connecting Tech Pros Worldwide Forums | Help | Site Map

Multiple Filtering on a subform

Doug
Guest
 
Posts: n/a
#1: Nov 12 '05
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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = "[EKCNBR]
=" & Me![bxAcctNbr]

Forms![frmPaymentSearch].[sbfrmPaymentSearch].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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.FilterOn = True

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

Allen Browne
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Multiple Filtering on a subform


strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
""2"")"
Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
Forms![frmPaymentSearch].[sbfrmPaymentSearch].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.0404281923.62b06db1@posting.google.c om...[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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = "[EKCNBR]
> =" & Me![bxAcctNbr]
>
> Forms![frmPaymentSearch].[sbfrmPaymentSearch].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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
> Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.FilterOn = True
>
> Can anyone figure this out? Thanks for any help you can provide[/color]


Doug
Guest
 
Posts: n/a
#3: Nov 12 '05

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@SeeSig.Invalid> wrote in message news:<40909bc1$0$16585$5a62ac22@freenews.iinet.net .au>...[color=blue]
> strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
> ""2"")"
> Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
> Forms![frmPaymentSearch].[sbfrmPaymentSearch].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.0404281923.62b06db1@posting.google.c om...[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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = "[EKCNBR]
> > =" & Me![bxAcctNbr]
> >
> > Forms![frmPaymentSearch].[sbfrmPaymentSearch].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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
> > Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.FilterOn = True
> >
> > Can anyone figure this out? Thanks for any help you can provide[/color][/color]
Allen Browne
Guest
 
Posts: n/a
#4: Nov 12 '05

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.0404290722.53a3390c@posting.google.c om...[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@SeeSig.Invalid> wrote in message[/color]
news:<40909bc1$0$16585$5a62ac22@freenews.iinet.net .au>...[color=blue][color=green]
> > strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
> > ""2"")"
> > Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
> > Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.FilterOn = True
> >
> > "Doug" <doug.corey@cox.com> wrote in message
> > news:1ebb60c8.0404281923.62b06db1@posting.google.c om...[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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = "[EKCNBR]
> > > =" & Me![bxAcctNbr]
> > >
> > > Forms![frmPaymentSearch].[sbfrmPaymentSearch].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![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
> > > Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.FilterOn = True
> > >
> > > Can anyone figure this out? Thanks for any help you can provide[/color][/color][/color]


Doug Corey
Guest
 
Posts: n/a
#5: Nov 12 '05

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!
Closed Thread