473,569 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AND function in a single criteria in Access/Excel

1 New Member
I have a table with company, products, local product and country.

I want to search that if a company has particular two products then display company, products, local product and country.

For example.,
If company A has pencil and eraser then display all the records.
Dec 6 '18 #1
2 1233
twinnyfo
3,653 Recognized Expert Moderator Specialist
musicfreak1203,

Welcome to Bytes!

Your question is a bit vague, but I think I understand what you are asking.

The theoretical answer is that you will want to use a sub-query that finds all the comapnies that have those two products. However, as I have found in the past, finding a company that has "either" of those products is easy. Finding the company that has "both" is more challenging.

However, your query could look something like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM tblCompanyProducts 
  3. WHERE Company IN ( 
  4.     SELECT Company 
  5.     FROM tblCompanyProducts 
  6.     WHERE Products = "Pencil") 
  7. AND Company IN (
  8.     SELECT Company 
  9.     FROM tblCompanyProducts 
  10.     WHERE Products = "Eraser") 
  11. ORDER BY Company, Products;
Hope this hepps!
Dec 6 '18 #2
NeoPa
32,564 Recognized Expert Moderator MVP
Two points :
  1. If your one table really has those fields in it then I suggest you throw it away and start again using more conventional design techniques (See Database Normalisation and Table Structures).
  2. I won't delete the question due to its being too inadequate, but only because it already has an answer. It really isn't acceptable to to post questions on here that are simply throwing a couple of sentences together. If you want people to spend their time helping you then a few minutes of proper preparation isn't an unreasonable expectation. It's actually a site requirement anyway.
Dec 6 '18 #3

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

Similar topics

3
9182
by: canigou9 (remove your socks to reply) | last post by:
(cross posted - comp.databases.ms-access, microsoft.public.access) Hello folks - this is my first post here, after a short lurk. I have written an application in Access2002 for a friend's business which allows him to take orders, arrange deliveries and trace deliveries back in the event of subsequent complaints. It uses a handful of...
10
7646
by: dchow | last post by:
Is it possible to call a subroutine or function whose name is in a string?
7
781
by: Alex | last post by:
Hi all, I've found a module that I think will help me combine fields properly, but I'm unsure how to add or use it with Access 2000. Below is the module I'd like to add: http://www.mvps.org/access/modules/mdl0008.htm In Access, I goto Modules and create new. Leaving 'Option Compare Database' on top I paste the module code in and save...
1
11623
by: tkaleb | last post by:
I have to create output file in a text, MS Access, MS Excel and .dbf format from C# Win/ADO.NET application. Data are collected in DataSet and there is no problem to make text file. However, I have to create a new output files (tables with defined fields) in other 3 formats, and to fill them with data from DataSet. I created Excel output with...
3
10714
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1 As Excel.Worksheet Set appExcel = New
2
2043
by: freegnu | last post by:
how to declare a friend function that can access two class it will look like the following class A { private: int i; public: A(){} ~A(){} friend void call(A &a, B &b);
2
3253
by: sbettadpur | last post by:
hello I am getting following error while connecting to mysql through php Warning: mysql_connect() : Access denied for user: 'pds@localhost' (Using password: YES) Actually I hosted one website on linux server, there i uploaded php script to the server, in that script i am trying to connect to the mysql, but i am getting above said...
0
1535
by: Nadirsha Muhammed | last post by:
How to access excel function wizard through C#
3
2824
by: keirnus | last post by:
Hello once again... I made a function in Excel. The function does some error checking within the Excel file. To be easy for me, I want my code in MS Access to simply call the function in Excel. I check this MS Support site: http://support.microsoft.com/kb/198571 I tried calling my function and it didn't work. Here's my MS Access code:
5
9118
by: lisles | last post by:
i have a page funtion.php which hs the function to connect to the db /* Mysql Connection */ function connect(){ global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php $conn = @mysql_connect($db_server,$db_user,$db_pass) or die("Connection to Database Server Failed"); @mysql_select_db($db) or die("Database Selection...
0
7701
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...
0
7924
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. ...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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...
1
5514
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...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.