473,385 Members | 1,712 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,385 software developers and data experts.

Filter by more than one criteria via vba

I have on my main form two control text boxes: "ContractNo" and "Buyer", I also have a form control subform: "Contracts".

Using the following code, If I enter "25" in the "Buyer" Control, this will filter the "Contracts Subform to show only the entries with buyer 25.

Private Sub Buyer_AfterUpdate()
Forms![outofstockmain]![ContractsSubform].Form.Filter = "[cbuyer]=" & Me.Buyer
Forms![outofstockmain]![ContractsSubform].Form.FilterOn = True
End Sub

Also using the following code, if I enter "11" in the "ContractNo" control, this will filter the "Contracts Subform to show only the entries with contract 11.

Private Sub ContractNo_AfterUpdate()
Forms![outofstockmain]![ContractsSubform].Form.Filter = "[cccno]=" & Me.ContractNo
Forms![outofstockmain]![ContractsSubform].Form.FilterOn = True
End Sub

My problem is I can only filter one or the other, Not both at once. I've tried using Forms![outofstockmain]![ContractsSubform].Form.Filter = "[cccno]=" & Me.ContractNo And "[cbuyer]=" & Me.Buyer, but I keep getting Type Mismatch.

Your help would be appreciated
Aug 24 '09 #1

✓ answered by ajalwaysus

you need to put the "And" in the double quotes and you missed a "&"..

Expand|Select|Wrap|Line Numbers
  1. Forms![outofstockmain]![ContractsSubform].Form.Filter = "[cccno]=" & Me.ContractNo & " AND [cbuyer]=" & Me.Buyer
  2.  
-AJ

2 6205
ajalwaysus
266 Expert 100+
you need to put the "And" in the double quotes and you missed a "&"..

Expand|Select|Wrap|Line Numbers
  1. Forms![outofstockmain]![ContractsSubform].Form.Filter = "[cccno]=" & Me.ContractNo & " AND [cbuyer]=" & Me.Buyer
  2.  
-AJ
Aug 24 '09 #2
Thank you, It works Great.
Aug 24 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Robin Cull | last post by:
Imagine I have a dict looking something like this: myDict = {"key 1": , "key 2": , "key 3": , "key 4": } That is, a set of keys which have a variable length list of associated values after...
4
by: Chris Geihsler | last post by:
I have a set of udf's dealing that return a one column table of values parsed from a comma delimeted string. For example: CREATE FUNCTION . ( @patient_list varchar(2000) ) RETURNS...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
3
by: Afton | last post by:
I would like to make a form that filters a report by Supervisor and by starting and ending date. I have the supervisors in a combo box, and that works. However, I do not know how to code to let...
4
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced...
3
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
2
by: tjdoss | last post by:
I am trying to display the "Filter by Form" criteria in a Report (that displays the filtered information). I have an unbound textbox with !. as the control source that will give me the Filter itself...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
3
by: remdeb648 | last post by:
Hi, I am programming a multi-criteria filter in an Access Data Page. I successed to make a simple criteria filter using the code below: (the code is on a button click action) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.