keyword parameter query

hi there

Registered User.
Local time
Today, 18:36
Joined
Sep 5, 2002
Messages
171
hello all,

i'm trying to set up a parameter query that runs from an input form when you enter a keyword into a text box. basically, i have a field "[composition]" that lists a bunch of components such as C4, C5, C6,....etc. as an example, i'd like to have the user enter "C5" into the text box and have the query list all of the records that contain C5 in the composition field. i should mention that the composition field has been entered with different values separated by a comma, such as

record 1: composition field = C3, C4, C6
record 2: composition field = C6, C7, C8

i tried to do this using the Like() function to build a parameter query. i used the following expression:

Like ([Forms]![keyword search form]![keyword text box entry])

this didn't work, so i then tried adding parentheses and using:

Like ("[Forms]![keyword search form]![keyword text box entry]")

this didn't work either. can someone help me with this. i'm totally confused. any help will be GREATLY appreciated.

thanks everyone
 
Oh so close, here ya go:

Like "*" & [Forms]![keyword search form]![keyword text box entry] & "*"

That should work!
 
Thanks pdx_man. that worked perfectly. could you explain to me why i need the "&" symbols. i understand why i needed the asterisks (*) before and after the reference, but i'm confused about the "&" symbols. also i'm not sure why i need the parentheses after the asterisks. for example why wouldn't this work?


Like "* & [Forms]![keyword search form]![keyword text box entry] & *"


thanks again for the response. i was really confused and your post really helped me out.
 
1) The ampersand, &, is used to concatonate stuff together. Let's say you wanted to put together the part of someones name to display it like:

Lastname, Firstname

Your expression would look like this:

[Lastname] & ", " & [Firstname]

We have three parts that are squished (concatonated) together to show as 1 item. So, that's what the & does.

2) If you look up Like in Access help, you will see that if you wanted to return records that contained, lets say, co. Our expression would be:

Like "*co*"

If we wanted records that begin with co:

Like "co*"

End with co:

Like "*co"

Whatever is within the double quotes is what will be the criteria. It does recognize the asterisk, *, as a wildcard.

Now, in your case, the co part can be variable, it is being pulled from a form, so we have to build the expression, like we built our name up above.

Is that clearer?
 
Thanks again for the response. your explanation was very clear.
 

Users who are viewing this thread

Back
Top Bottom