473,396 Members | 1,879 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.

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******@removethispart.hotmail.com
Nov 12 '05 #1
2 1657
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*****@microsoft.com> wrote in message
news:c7**********@daisy.noc.ucla.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******@removethispart.hotmail.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********@stantonfamily.co.uk> wrote in message
news:40***********************@mercury.nildram.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
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...
3
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...
1
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...
1
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. ...
4
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
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...
17
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...
7
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,...
6
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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.