473,785 Members | 2,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Criteria with wild cards AND variables

This is what I'm trying to do:

In a form, a user enters a value (e.g. John) and clicks on submit.

Submit opens up a query with one of its values (e.g. Name) set to the value
of the control that the user just typed "John" into.

Thus far, this works fine, and it pulls up all the records where Name =
John.

But I want it to pull up all records where Name = John, John Smith, John
Jones, John Jacobs, Father John, etc. -- in other words, if John is in any
part of the control, I want it to come back.

If I put Like "*John*" in the criteria, it works fine.

But if I put Like "[Forms]![Submit Form]![Name]*" it returns no records
(because it looks for names with the value "[Forms]!...")

If I put Like [Forms]![Submit Form]![Name]* or Like [Forms]![Submit
Form]![Name]"*" it returns with a syntax error.

Obviously I won't always be looking for John, so I would like to do this
with a variable.

Any idea how to do what I want to do? Thanks!
ph******@remove thispart.hotmai l.com
Nov 12 '05 #1
2 1682
Try something like

Like "*" & Left$([forms]![Submit Form]![Name],Len([forms]![Submit
Form]![Name] & "*"

The Len(....) part defines how many letters you want to search on (in the
case of John you will look for at least 4 letters)

HTH

Phil
"John Smith" <so*****@micros oft.com> wrote in message
news:c7******** **@daisy.noc.uc la.edu...
This is what I'm trying to do:

In a form, a user enters a value (e.g. John) and clicks on submit.

Submit opens up a query with one of its values (e.g. Name) set to the value of the control that the user just typed "John" into.

Thus far, this works fine, and it pulls up all the records where Name =
John.

But I want it to pull up all records where Name = John, John Smith, John
Jones, John Jacobs, Father John, etc. -- in other words, if John is in any
part of the control, I want it to come back.

If I put Like "*John*" in the criteria, it works fine.

But if I put Like "[Forms]![Submit Form]![Name]*" it returns no records
(because it looks for names with the value "[Forms]!...")

If I put Like [Forms]![Submit Form]![Name]* or Like [Forms]![Submit
Form]![Name]"*" it returns with a syntax error.

Obviously I won't always be looking for John, so I would like to do this
with a variable.

Any idea how to do what I want to do? Thanks!
ph******@remove thispart.hotmai l.com

Nov 12 '05 #2
Thanks! I'm not sure why I would use Left or Len, so instead I just did

Like "*" & [Forms]![Submit Form]![Name] & "*"

Which worked like a charm. Thanks for the help!

John

"Phil Stanton" <di********@sta ntonfamily.co.u k> wrote in message
news:40******** *************** @mercury.nildra m.net...
Try something like

Like "*" & Left$([forms]![Submit Form]![Name],Len([forms]![Submit
Form]![Name] & "*"

The Len(....) part defines how many letters you want to search on (in the
case of John you will look for at least 4 letters)

HTH

Phil

Nov 12 '05 #3

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

Similar topics

1
1727
by: Steve T | last post by:
I have just contracted with a firm that is using a front-end web interface to access our sales data. They developed it with Microsoft Dotnet, and it uses Microsoft SQL as the database. When I search test/note fields, they say I have to do a wild card search *word* to pull up any records with "word" in that field. With our previous vendor, and with many other web accessable data bases I search you usually do not need the wild cards,...
3
2395
by: topmind | last post by:
I need to search for database text with underlines in it. However, underlines are interpreted as wild-cards in LIKE clause text . I need to know how to escape the underlines so as to be able to search them. Some DB's use an "Escape" keyword and others use a back-slash to escape wild-cards. However, Jet does not seem to support either of these. Note that I am accessing Access files via ODBC and ADO (or is it DAO?) and not through Access...
1
1635
by: Jer | last post by:
I have a query that uses LIKE in the criteria. The criteria I am using is: LIKE "Program*". When I look at the query results it works fine. When I try to open the query as a recordset using Dim cp_data As Recordset Set cp_data = New Recordset cp_data.Open "xxxTEST", CurrentProject.Connection, adOpenStatic, adLockOptimistic I don't get any records. ("xxxTEST" is the name of my test query) What is different using the LIKE criteria from...
1
2764
by: panchaga | last post by:
Hi, could any one help me with this select statement. i am using as part of JSP page. i want to use wild cards as part of this select. i am getting error when i use % along with the name. rs = statement.executeQuery("SELECT * FROM lessons WHERE fname='"+ name+ "'"); Thanks
4
5200
by: MattWilson.6185 | last post by:
Hi, I was wondering if there is any type of way to specify a generic type for a list. I basicaly have class shape { } class circle: public shape { }; class triangle: public shape {
1
1875
by: Nitinkcv | last post by:
Hi, I have a textbox and a button. In my textbox i have to enter the query string(say shoes) and on clicking the button takes me to a page show all item related to the search string( in this case shoes). But on mixing the search string with wildcards it displays that no items could be found. For eg: for search string s@h^o$e@s it would go to the error page. So is there ant way i could like extract the wildcards out of my search string...
17
5699
by: sharsy | last post by:
Hello guys, I would like some help in generating query criteria that will identify credit cards that have expired on an access database. The specific Field is formatted with a Data Type of 'Text' and has an input mask of '00/00', so all expiry dates are set out for example as 10/13 (which represents October 2013). I have hada brief go at trying to work it out, but I was unable to
7
9261
by: W. eWatson | last post by:
Is it possible to do a search for a wild card string in another string. For example, I'd like to find "v*.dat" in a string called bingo. v must be matched against only the first character in bingo, and not simply found somewhere in bingo, as might be the case for "*v*.dat". -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
6
1850
by: Cody12345 | last post by:
I have a several rows say Location part # product code 105 E05 DX 104 1740 DX 104 2047 DX I want a way to find a way in chriteria thet i can find all related info on these parts. When i ran this query it only gave me the product code DX
0
9645
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
10325
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.