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

like statement in SQL query in Access

I am using a form to find some data from a table. In the table are
fields such as Client name, job number, and job description. I built a
query using a SQL statement through the 'Record source' for the form. I
can get the query to work if I type in the Client name exactly as it is
in the table. However, I want to be able to use a like statement to
expand my search and find all records with a certain word or year in
it. How can I get this to work?
Currently the SQL statement looks like: SELECT [CD Query].* FROM [CD
Query] WHERE ((([CD Query].[PROJECT NUMBER])=Forms!CDtest!scanned));
CD Query is the name of the Query, I'm searching by project number,
CDtest is the name of the form, and scanned is the name of the text box
where I enter what I'm looking for.
Any help is greatly appreciated. Thanks!

Jul 22 '05 #1
1 3660
I assume you submit the form, and aren't trying to do this as the user is on
the page.

sql = "SELECT * FROM [CD Query] WHERE [Project Number] LIKE '%" &
replace(request.form("scanned"), "'", "''") & "%'"

You really should consider better object names. Why the spaces? Do you
like typing square brackets all over the place? And try to avoid SELECT *
in production code.

Also, you might find this page useful:
http://www.aspfaq.com/2183

"ITHELP" <od****@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I am using a form to find some data from a table. In the table are
fields such as Client name, job number, and job description. I built a
query using a SQL statement through the 'Record source' for the form. I
can get the query to work if I type in the Client name exactly as it is
in the table. However, I want to be able to use a like statement to
expand my search and find all records with a certain word or year in
it. How can I get this to work?
Currently the SQL statement looks like: SELECT [CD Query].* FROM [CD
Query] WHERE ((([CD Query].[PROJECT NUMBER])=Forms!CDtest!scanned));
CD Query is the name of the Query, I'm searching by project number,
CDtest is the name of the form, and scanned is the name of the text box
where I enter what I'm looking for.
Any help is greatly appreciated. Thanks!

Jul 22 '05 #2

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

Similar topics

5
by: Jahmil Richardson | last post by:
Attempting to query MS Access database with the ODBC drivers for PHP. When using the LIKE statement no records are returned. Example: $query = " Select * From Dispatch Where Customer Like...
7
by: Bob | last post by:
Currently I am using this statement to translate 3 fields in my db thru Visual Basic. I import the data from one table to another then call the IFF statements and the NewDate to translate the...
3
by: Peter Phelps | last post by:
My problem is as follows: I need automatically iterate through a single field in a table and use the values in the field to create an in-statement. Currently, the character limitation in the...
4
by: Polly | last post by:
I had a macro that ran a parameter query and created and opened an Excel file with the system date as part of the file name, but I had to change the file name by hand. So I converted the macro to...
2
by: Michael C | last post by:
Hi all. When I run the following query against my Access database - from within Access - it returns the correct results (5 records in this instance): SELECT * FROM WHERE = "Clothes" AND LIKE...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
4
by: Dave | last post by:
I have a field with data type of memo in my access database. I run a query from c# to access this field and it cuts off my string to only 255 characters. If i run this query directly in access...
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...
0
ADezii
by: ADezii | last post by:
One frequently asked question at TheScripts is "Should I use a Stored Query or an SQL Statement in those situations that require a Query (RecordSets, RecordSources, Append, Delete, Update Operations,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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.