473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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![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
Nov 12 '05 #1
4 8887
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" <do********@cox.com> wrote in message
news:1e**************************@posting.google.c om...
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

Nov 12 '05 #2
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" <Al*********@SeeSig.Invalid> wrote in message news:<40***********************@freenews.iinet.net .au>...
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" <do********@cox.com> wrote in message
news:1e**************************@posting.google.c om...
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

Nov 12 '05 #3
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" <do********@cox.com> wrote in message
news:1e**************************@posting.google.c om...
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" <Al*********@SeeSig.Invalid> wrote in message

news:<40***********************@freenews.iinet.net .au>...
strfilter = "([EKCNBR] = """ & Me![bxAcctNbr] & """) And ([BREAKLVL] =
""2"")"
Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.Filter = strfilter
Forms![frmPaymentSearch].[sbfrmPaymentSearch].Form.FilterOn = True

"Doug" <do********@cox.com> wrote in message
news:1e**************************@posting.google.c om...
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

Nov 12 '05 #4
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!
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
3
by: arthur-e | last post by:
I can filter a query for a report on a field of a subform BUT now.... I'd like to be able to select more than one item in a multi-list box to select all the records. ALSO to use two fields (or...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
4
by: Doug | last post by:
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...
3
by: Todd | last post by:
Hi, I've been told in another forum that I can apply a filter to a subform (from a control on the main form) by using the following code: Me.sfrMySubform.Filter = " = 7" I've tried this...
2
by: Katie | last post by:
I need to store a history of two fields in two seperate tables: Event - where the key is Event_ID Stage - where the key is Stage_ID The joins are: Main Table Event Table Stage Table ...
3
by: paquer | last post by:
On my Main form I have a Command Button that opens a Subform in order to create a new Subform record. At this point I want the subform to show only the new record being created. Not all the...
1
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes...
64
by: lovelydan | last post by:
hi all i need someone to help me with a code that will enable me filter records in a subform form through a combo box attached to a mainform-that has a main menu that controls all the sub form...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.