473,400 Members | 2,145 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,400 software developers and data experts.

Using LIKE in a Parameter Query - Access 2000

I am not a real well versed query writer and therefore am having some problems figuring out how to write a parameter query where I want to input a partial name. I have tried a few different things, but either get no results or all of the records in BANKS are returned.

I am using Access 2000 on XP. I am using three tables for this query:
Expand|Select|Wrap|Line Numbers
  1. BANKS
  2.   BankID (pk)
  3.   BankName
  4.   Other fields that are not pertinent to this query
Expand|Select|Wrap|Line Numbers
  1. VENDORS
  2.   VendorID (pk)
  3.   VendorName
  4.   Other fields that are not pertinent to this query
Expand|Select|Wrap|Line Numbers
  1. BANKVENDORS
  2.   BankID
  3.   VendorID (both fields combined make up the pk)
I want to list the BankName and VendorName based on VendorName. I am using BANKVENDORS to link the two tables. Since the VendorName is generally long (i.e. Federal Reserve Bank of Atlanta), I want the user to be able to enter only a portion of the VendorName (i.e. Atlanta) and have the query return all Banks and Vendors where the VendorName contains the word Atlanta.

Here is what I have so far in the query (I used the Wizard to create it):
Expand|Select|Wrap|Line Numbers
  1. SELECT Banks.BankName, Vendors.VendorName
  2. FROM Vendors INNER JOIN (Banks INNER JOIN BankVendors ON Banks.BankID = BankVendors.BankID) ON Vendors.VendorID = BankVendors.VendorID
  3. WHERE (((Vendors.VendorName)=[Enter Vendor Name]));
Thanks for any help you can provide.

-Carolyn
Feb 2 '08 #1
4 2898
FishVal
2,653 Expert 2GB
Hi, Carolyn.

Try
Expand|Select|Wrap|Line Numbers
  1. SELECT Banks.BankName, Vendors.VendorName
  2. FROM Vendors INNER JOIN (Banks INNER JOIN BankVendors ON Banks.BankID = BankVendors.BankID) ON Vendors.VendorID = BankVendors.VendorID
  3. WHERE (((Vendors.VendorName) ='*' & [Enter Vendor Name] & '*'));
  4.  
or, if SQL syntax option in your db is set to ANSI92, then

Expand|Select|Wrap|Line Numbers
  1. SELECT Banks.BankName, Vendors.VendorName
  2. FROM Vendors INNER JOIN (Banks INNER JOIN BankVendors ON Banks.BankID = BankVendors.BankID) ON Vendors.VendorID = BankVendors.VendorID
  3. WHERE (((Vendors.VendorName) ='%' & [Enter Vendor Name] & '%'));
  4.  
Regards,
Fish
Feb 2 '08 #2
NeoPa
32,556 Expert Mod 16PB
I think you need to replace the "=" with "LIKE" in Fish's examples.
Expand|Select|Wrap|Line Numbers
  1. SELECT Banks.BankName,
  2.        Vendors.VendorName
  3. FROM Vendors INNER JOIN (Banks INNER JOIN BankVendors
  4.   ON Banks.BankID = BankVendors.BankID)
  5.   ON Vendors.VendorID = BankVendors.VendorID
  6. WHERE (Vendors.VendorName LIKE '*' & [Enter Vendor Name] & '*')
If you're using Access 2000, it will only support ANSI89 I think.
Feb 5 '08 #3
FishVal
2,653 Expert 2GB
Ooops.
Certainly "=" is a typo. It should be "LIKE".
Thanks NeoPa.
Feb 6 '08 #4
NeoPa
32,556 Expert Mod 16PB
No worries my friend. We're all part of a good team :)
Feb 6 '08 #5

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

Similar topics

3
by: Richard Muller | last post by:
Hi All, I've got the ASP script shown below that complains as follows: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Data source name not found and no default driver specified...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
2
by: ILCSP | last post by:
Hello, I'm in the process of changing our 'normal' Access 2000 update queries to Update Pass Through Queries. We have a SQL server 2000 database and we're using an Access 2000 database as our...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
8
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table,...
3
by: Clearview | last post by:
This is my first post to the forum and hoping I can get help as I have spent a way too much time on this problem, and thinking it is probably something really simple to resolve. I am using Access...
2
by: deanoooo812 | last post by:
I have an Access query (written in MS Access 2000 - thats all we've got - don't get me started on that topic...) for making pharmacy dispensing labels based on an extract from an automated dispensing...
2
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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,...

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.