473,799 Members | 3,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filter by more than one criteria via vba

5 New Member
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_AfterUpda te()
Forms![outofstockmain]![ContractsSubfor m].Form.Filter = "[cbuyer]=" & Me.Buyer
Forms![outofstockmain]![ContractsSubfor m].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_Afte rUpdate()
Forms![outofstockmain]![ContractsSubfor m].Form.Filter = "[cccno]=" & Me.ContractNo
Forms![outofstockmain]![ContractsSubfor m].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]![ContractsSubfor m].Form.Filter = "[cccno]=" & Me.ContractNo And "[cbuyer]=" & Me.Buyer, but I keep getting Type Mismatch.

Your help would be appreciated
Aug 24 '09 #1
2 6232
ajalwaysus
266 Recognized Expert Contributor
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
ccmanc68
5 New Member
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
12242
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 them. What I want to do is filter out a subset of this dict to produce another dict that satisfies a set of criteria (in this case whether it contains all four values) to end up with something
4
12301
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 @patient TABLE
0
6476
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 report are based on the same View addressed in the Record Source of both as 'dbo.CLMain_vw'. The View resides in a SQL Server 2000 database. There are two different problems I am having with filtering: The first involves filtering in the form by date...
3
2912
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 the user enter a starting and ending date and only show the records between those dates. The code that I have so far does not work for the dates, but I'm including it anyway so you show me what to change. Thanks so much! :) Here is my code (the...
4
5140
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 Filter/Sort window: A window in which you can create a filter from scratch. You enter criteria expressions in the filter design grid to restrict the records in the open form or datasheet to a subset of records that meet the criteria.), you see the design...
3
11973
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 subform..... This MSDN article however makes it sound as simple as clicking "Filter by Form", entering the search criterial in the form and/or it's subforms, then just clicking "Apply Filter"...... ...
1
16391
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 VBA to create SQL statements, then apply them. Now that I have been using Access/VBA for awhile, I am wondering if there is a simpler way to do this than coding these long sql statements. My report has a query as its record source. Can I just...
2
2369
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 but I need to clean this up. I envisioned a listing in the header of the report that would list each of the categories (there are six) and the filter criteria specified for the category. This is a demographics database application for a Fire...
5
2660
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 this... Exmaple web site: http://allenbrowne.com/ser-62.html My Code: 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few criteria as they wish, _ and results...
3
1848
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) MSODSC.DataPages(0).Filter = "Status= '" & SSTATUS.value & "'" If MSODSC.DataPages(0).IsFilterOn then
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10491
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.