473,662 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with search - using query

hi,

i have created a search form, and i want to search for a specific item in a
field.
e.g. i have a field called colour, which has record1 = 'red, blue, green'
and another record2 = 'red'

now, when i do the search, and only type in red, to search for red, it only
brings back record 2, and not record 1 as well.

y is this? because i have used a comma?
how would i make it return record 1 as well, as it contains 'red' as well.

TIA

Jon
Mar 14 '06 #1
7 1710
Your query is returning the correct record - its matching anything that
exactly matches your criteria (in this case 'red')

To return all records containing 'red', you would need to add a LIKE
clause, which will will return records that contain the word 'red'
within the field.

To do this, open the query in design mode, put the following in the
criteria (below) for the field, colour

LIKE "*red*"

Note the asterisks before and after the word 'red', this tells the
query to search for any instance of 'red' within the field.

Hope this helps.

Cheers

phil

John wrote:
hi,

i have created a search form, and i want to search for a specific item in a
field.
e.g. i have a field called colour, which has record1 = 'red, blue, green'
and another record2 = 'red'

now, when i do the search, and only type in red, to search for red, it only
brings back record 2, and not record 1 as well.

y is this? because i have used a comma?
how would i make it return record 1 as well, as it contains 'red' as well.

TIA

Jon


Mar 14 '06 #2
but what if i wanted to search for blue, or any other colour?

e.g.
record 1 = red, blue, green
record 2 = red
record 3 = red, blue
record 4 = green

so if i searched for red, it would display record 1,2 and 3.
if i search for green, it would display record 1 and 2.

the colours i have mentioned are not in their own seprate fields, they are
in one field called colour.

this is what i currently have in the query;

[Forms]![frmItem]![txtColour]

which basiclly looks in txtcolour field (for any input), and when the search
button is clicked, it loads a query, containing the required informaiton.

dev

"Phil Latio" <ph********@lyc os.co.uk> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Your query is returning the correct record - its matching anything that
exactly matches your criteria (in this case 'red')

To return all records containing 'red', you would need to add a LIKE
clause, which will will return records that contain the word 'red'
within the field.

To do this, open the query in design mode, put the following in the
criteria (below) for the field, colour

LIKE "*red*"

Note the asterisks before and after the word 'red', this tells the
query to search for any instance of 'red' within the field.

Hope this helps.

Cheers

phil

John wrote:
hi,

i have created a search form, and i want to search for a specific item in a field.
e.g. i have a field called colour, which has record1 = 'red, blue, green' and another record2 = 'red'

now, when i do the search, and only type in red, to search for red, it only brings back record 2, and not record 1 as well.

y is this? because i have used a comma?
how would i make it return record 1 as well, as it contains 'red' as well.
TIA

Jon

Mar 14 '06 #3
"John" <jo*****@hotmai .com> wrote in
news:Fe******** *********@newsf e7-win.ntli.net:

Follow the advice that Phil gave you.
LIKE "*" & [Forms]![frmItem]![txtColour] & "*"

Q
but what if i wanted to search for blue, or any other colour?

e.g.
record 1 = red, blue, green
record 2 = red
record 3 = red, blue
record 4 = green

so if i searched for red, it would display record 1,2 and 3.
if i search for green, it would display record 1 and 2.

the colours i have mentioned are not in their own seprate
fields, they are in one field called colour.

this is what i currently have in the query;

[Forms]![frmItem]![txtColour]

which basiclly looks in txtcolour field (for any input), and
when the search button is clicked, it loads a query,
containing the required informaiton.

dev

"Phil Latio" <ph********@lyc os.co.uk> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Your query is returning the correct record - its matching
anything that exactly matches your criteria (in this case
'red')

To return all records containing 'red', you would need to add
a LIKE clause, which will will return records that contain
the word 'red' within the field.

To do this, open the query in design mode, put the following
in the criteria (below) for the field, colour

LIKE "*red*"

Note the asterisks before and after the word 'red', this
tells the query to search for any instance of 'red' within
the field.

Hope this helps.

Cheers

phil

John wrote:
> hi,
>
> i have created a search form, and i want to search for a
> specific item in a > field.
> e.g. i have a field called colour, which has record1 =
> 'red, blue, green' > and another record2 = 'red'
>
> now, when i do the search, and only type in red, to search
> for red, it only > brings back record 2, and not record 1 as well.
>
> y is this? because i have used a comma?
> how would i make it return record 1 as well, as it contains
> 'red' as well. >
> TIA
>
> Jon



--
Bob Quintal

PA is y I've altered my email address.
Mar 14 '06 #4
Hi,

the code you gave me worked, however, now when i do a search for something
else, all the records load up, instead of the ones i need.

what does the * mean? what does it do, as it seems to have messed up my
other searches. now when i click the search button, all the records are
shown.

thank you

John

"Bob Quintal" <rq******@sympa tico.ca> wrote in message
news:Xn******** **************@ 207.35.177.135. ..
"John" <jo*****@hotmai .com> wrote in
news:Fe******** *********@newsf e7-win.ntli.net:

Follow the advice that Phil gave you.
LIKE "*" & [Forms]![frmItem]![txtColour] & "*"

Q
but what if i wanted to search for blue, or any other colour?

e.g.
record 1 = red, blue, green
record 2 = red
record 3 = red, blue
record 4 = green

so if i searched for red, it would display record 1,2 and 3.
if i search for green, it would display record 1 and 2.

the colours i have mentioned are not in their own seprate
fields, they are in one field called colour.

this is what i currently have in the query;

[Forms]![frmItem]![txtColour]

which basiclly looks in txtcolour field (for any input), and
when the search button is clicked, it loads a query,
containing the required informaiton.

dev

"Phil Latio" <ph********@lyc os.co.uk> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Your query is returning the correct record - its matching
anything that exactly matches your criteria (in this case
'red')

To return all records containing 'red', you would need to add
a LIKE clause, which will will return records that contain
the word 'red' within the field.

To do this, open the query in design mode, put the following
in the criteria (below) for the field, colour

LIKE "*red*"

Note the asterisks before and after the word 'red', this
tells the query to search for any instance of 'red' within
the field.

Hope this helps.

Cheers

phil

John wrote:
> hi,
>
> i have created a search form, and i want to search for a
> specific item

in a
> field.
> e.g. i have a field called colour, which has record1 =
> 'red, blue,

green'
> and another record2 = 'red'
>
> now, when i do the search, and only type in red, to search
> for red, it

only
> brings back record 2, and not record 1 as well.
>
> y is this? because i have used a comma?
> how would i make it return record 1 as well, as it contains
> 'red' as

well.
>
> TIA
>
> Jon



--
Bob Quintal

PA is y I've altered my email address.

Mar 18 '06 #5
"John" <jo*****@hotmai .com> wrote in
news:gC******** *********@newsf e3-gui.ntli.net:
Hi,

the code you gave me worked, however, now when i do a search
for something
else, all the records load up, instead of the ones i need.

what does the * mean? what does it do, as it seems to have
messed up my other searches. now when i click the search
button, all the records are shown.

thank you

John
Access has a help system. It will explain wildcard searches in
far greater detail that can be done in a post.

In summary LIKE uses the wild cards to show what can be anything
in the search. What's happening is that, when you leave the
textbox empty it searches for anything, and retuurns all entries
with any colour.
You can keep it from finding all the colours in your table by
entering a non-existing colour, say zzzzz. Another way is to
move the asterisks to the textbox, so you can control whether to
use them or not.

There are far more elegant solutions, but if you have to ask
what the * does, they are above your current ability to program
them.

..

"Bob Quintal" <rq******@sympa tico.ca> wrote in message
news:Xn******** **************@ 207.35.177.135. ..
"John" <jo*****@hotmai .com> wrote in
news:Fe******** *********@newsf e7-win.ntli.net:

Follow the advice that Phil gave you.
LIKE "*" & [Forms]![frmItem]![txtColour] & "*"

Q


--
Bob Quintal

PA is y I've altered my email address.
Mar 18 '06 #6
hi,

when u say move the asterisks to a text box, what do you mean? do you mean
refer it to another field in the form? e.g. LIKE
"[Forms]![frmItem]![txtSize]" & [Forms]![frmItem]![txtColour] &
"[Forms]![frmItem]![txtWeight]"

or do you mean refer to the fields in the table?
could you explain a bit more please.
what are the other elegant solutions?

thanx

John

"Bob Quintal" <rq******@sympa tico.ca> wrote in message
news:Xn******** **************@ 207.35.177.135. ..
"John" <jo*****@hotmai .com> wrote in
news:gC******** *********@newsf e3-gui.ntli.net:
Hi,

the code you gave me worked, however, now when i do a search
for something
else, all the records load up, instead of the ones i need.

what does the * mean? what does it do, as it seems to have
messed up my other searches. now when i click the search
button, all the records are shown.

thank you

John

Access has a help system. It will explain wildcard searches in
far greater detail that can be done in a post.

In summary LIKE uses the wild cards to show what can be anything
in the search. What's happening is that, when you leave the
textbox empty it searches for anything, and retuurns all entries
with any colour.
You can keep it from finding all the colours in your table by
entering a non-existing colour, say zzzzz. Another way is to
move the asterisks to the textbox, so you can control whether to
use them or not.

There are far more elegant solutions, but if you have to ask
what the * does, they are above your current ability to program
them.

.

"Bob Quintal" <rq******@sympa tico.ca> wrote in message
news:Xn******** **************@ 207.35.177.135. ..
"John" <jo*****@hotmai .com> wrote in
news:Fe******** *********@newsf e7-win.ntli.net:

Follow the advice that Phil gave you.
LIKE "*" & [Forms]![frmItem]![txtColour] & "*"

Q


--
Bob Quintal

PA is y I've altered my email address.

Mar 18 '06 #7
"John" <jo*****@hotmai .com> wrote in
news:Hh******** *********@newsf e5-gui.ntli.net:
hi,

when u say move the asterisks to a text box, what do you
mean? do you mean
refer it to another field in the form? e.g. LIKE
"[Forms]![frmItem]![txtSize]" & [Forms]![frmItem]![txtColour]
& "[Forms]![frmItem]![txtWeight]"

or do you mean refer to the fields in the table?
could you explain a bit more please.
what are the other elegant solutions?

thanx

John
What I meant is let the user put the asterisks in the textbox,
when he wants them.
In the query
LIKE [Forms]![frmItem]![txtColour]

In the textbox: find where red is the only colour RED
find where red is the first colour user types RED*
find where red is the last colour user types *RED
find where red is colour anywhere user types *RED*

the elegant solutions are to write Visual Basic Code that
determines if the colour textbox should have wildcards added, or
to redesign the application so that the colour field has one
entry only.

Q

"Bob Quintal" <rq******@sympa tico.ca> wrote in message
news:Xn******** **************@ 207.35.177.135. ..
"John" <jo*****@hotmai .com> wrote in
news:gC******** *********@newsf e3-gui.ntli.net:
> Hi,
>
> the code you gave me worked, however, now when i do a
> search for something
> else, all the records load up, instead of the ones i need.
>
> what does the * mean? what does it do, as it seems to have
> messed up my other searches. now when i click the search
> button, all the records are shown.
>
> thank you
>
> John
>

Access has a help system. It will explain wildcard searches
in far greater detail that can be done in a post.

In summary LIKE uses the wild cards to show what can be
anything in the search. What's happening is that, when you
leave the textbox empty it searches for anything, and
retuurns all entries with any colour.
You can keep it from finding all the colours in your table by
entering a non-existing colour, say zzzzz. Another way is to
move the asterisks to the textbox, so you can control whether
to use them or not.

There are far more elegant solutions, but if you have to ask
what the * does, they are above your current ability to
program them.

.

> "Bob Quintal" <rq******@sympa tico.ca> wrote in message
> news:Xn******** **************@ 207.35.177.135. ..
>> "John" <jo*****@hotmai .com> wrote in
>> news:Fe******** *********@newsf e7-win.ntli.net:
>>
>> Follow the advice that Phil gave you.
>> LIKE "*" & [Forms]![frmItem]![txtColour] & "*"
>>
>> Q
>>


--
Bob Quintal

PA is y I've altered my email address.



--
Bob Quintal

PA is y I've altered my email address.
Mar 18 '06 #8

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

Similar topics

1
2763
by: Melissa Kay Beeline | last post by:
OK, here's the sitch : we have an access control system at work that registers ever entry/exit of every employee. I recently made some queries in Access so the ppl in HR could make reports (who came in late, how many ppl were undertimed, etc etc) Now they are not satisfied (of course) and they want a list of ABSENT employees. I have the following tables : PERSONNEL CARD
3
1501
by: ZafT | last post by:
Thanks for any help in advance. I am using this exact same piece of code on a server running PHP4, but for some reason when I run it on dreamhost using PHP5, the search does not register and it just lists all items. There's not much code, so I'm just putting it all in here. The script calls itself. Can someone please tell me why the if(!(isset($search))) is ignored when the form is posted? Thanks,
0
5558
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
3
3006
by: cuties | last post by:
Hi all.... i'm very new to this programming language. i'm required to fulfill this task in the company i'm doing my practical. i hope i can get guide for my problem... Here is the script i already wrote but i'm having problem to move forward. my problem is : 1. how do i assign each checkbox to have equal value with the value of the d_id?
5
2018
by: deaconj999 | last post by:
Hi, I have nearly finished my database and I would like to add a query that uses a combo box to get the results, not the usual paramater style input. I suppose it would need a form and a query and a combo box, but where to start !!!!!!!! Any kind soul out there that can give me an example of where to start..........?
5
3375
by: kanley | last post by:
I have a main table with a text description field. In this field, its populated with a string of data. I need to identify from this string of data the name of the vendor using some keywords. I have another table that contains 2 fields, one being the keywords to search for from the string of data and the other field being the vendor name to pair up with the record. How do I reference the keywords from the 2nd table and search thru the...
8
5095
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are indexed). dbo.maintable(ProfileID int pk) dbo.fts_table(ProfileID int pk fk, col1 xml, col2 xml, col3 xml) I want to perform a query that will return any rows that contain ‘x’ and ‘y’ in any columns. I.e. ‘x’ could be in col1 and ‘y’ could be in
7
2288
by: microsoftboy | last post by:
Hi, Using the following selection criteria, I am able to list the data from mysql db, but I would like to provide the following options for users: Select All Data, Select None. I am not sure if this is possiible. Any help would be greatly appreciated. Here's my code <h4>SEARCH</h4> <form action="<?php echo $_SERVER ?>" method = "post" target = "right">
0
8432
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
8344
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
8633
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
7367
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
6186
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
5654
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
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1752
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.