Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter Query - Adding a Wild Card 1

Status
Not open for further replies.

chucky2000

Technical User
May 29, 2002
10
US
Hi, I am using MS Access and running a Query on a Text Field using a Parameter. The Text field in question can contain many variants of a name. For example

Republic Brazil
Republica Brazil
Republica Brazil SA

I would like Users to be able to Input into this parameter box; for example 'Rep', and the query show all of these variables without having to input the correct name of the item.
Help would be appreciated.
Chucky
 
Try placing the parameter in the query's criteria inside the Like function.

Example:
Like([MyParameter]) God Bless
Mike ;-)
 
Use this little jeito as the parametric criterion:

[tt]
[Enter first three letters] & "*"[/tt]
 
I forgot the [tt]LIKE[/tt]

Mike forgot the [tt]& "*" [/tt] ;-)
 
thanks for getting back to me.
but unfortunately neither of these options worked.
thanks
 
Make sure the queries criteria is just like this:
Code:
=Like "*" & [MyParameter] & "*"
Surely this would work. God Bless
Mike ;-)
 
Sorry Mike it didn't like the Syntax.
Have you any other suggestions?
Chucky
 
I just tested the query field criteria and it worked correctly for me. Can you copy and paste the SQL statement into a reply and maybe I can help better? Maybe I don't understand fully what you are trying to do. God Bless
Mike ;-)
 
Mike, thanks for taking a look at this.
The SQL is below

SELECT ICT_ICT_TRANSACTION.SCHEDULED_TERMINATION_DATE, ICT_ICT_TRANSACTION.CHARACTER_4 AS REF_ENT, ICT_ICT_TRANSACTION.BOOK_CODE
FROM ICT_ICT_TRANSACTION
WHERE (((ICT_ICT_TRANSACTION.SCHEDULED_TERMINATION_DATE)>Date()) AND ((ICT_ICT_TRANSACTION.CHARACTER_4)=[MyParameter]))
ORDER BY ICT_ICT_TRANSACTION.BOOK_CODE;

 
You're asking for ICT_ICT_TRANSACTION.CHARACTER_4 to equal (=) something. If you want to enter less than the full and exact spelling then you have to use [tt]LIKE[/tt] (as Mike pointed out).

Here's something I just tested in my own db:
[tt]
SELECT TBL_CNTRYS.CNTRY_NAME
FROM TBL_CNTRYS
WHERE (((TBL_CNTRYS.CNTRY_NAME) Like [enter country] & "*"));
[/tt]
 
Quehay is correct. Here is the same prinicple applied to the query that you sent me.
Code:
SELECT ICT_ICT_TRANSACTION.SCHEDULED_TERMINATION_DATE, ICT_ICT_TRANSACTION.CHARACTER_4 AS REF_ENT, ICT_ICT_TRANSACTION.BOOK_CODE
FROM ICT_ICT_TRANSACTION
WHERE (((ICT_ICT_TRANSACTION.SCHEDULED_TERMINATION_DATE)>Date()) AND ((ICT_ICT_TRANSACTION.CHARACTER_4) Like "*" & [MyParameter] & "*"))
ORDER BY ICT_ICT_TRANSACTION.BOOK_CODE;
Try pasting this into a new query and see if it works like you desire.

God Bless
Mike ;-)
 
Thanks Guys it worked.
That was excellent.
Much appreciated.
Chucky
 
Sorry to bother you guys again but the Query I am running has some problems.
Would the Query not function as well if the table I am looking at is reasonably large, 9000 items?
Or possibly using Upper or Lower case.
I am having problems with bringing back the correct criteria when inputting the information in the Parameter.
Any ideas,
Many thanks,

Chucky
 
Access is not case-sensitive.

Are you trying to enter the parameter entirely in code?(Based on previous I don't think so.) This requires a different approach than opening the query normally.

Make sure you understand what your criterion is saying, i.e., "Show me anything that's got any char + 'rep' + any char, etc." Originally you said that you wanted to type 'rep' and get any variation of Republica do Brazil, etc. You probably don't want the wildcard (*) in front of the parameter--this is saying "Give me any string that has any number of different characters, or none, in front of 'rep'".
 
Hi everyone, I'm having the same problem with the LIKE command trying this: if i have a paramter with the letter m i want to find all the usernames where m is foud. i have tried all of the above but nothing seems to work. I'm using zope. can somebody help me please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top