473,624 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Like Clause in MS-Access

Can anyone tell me why the following statement doesnt work?

DoCmd.OpenForm "frmSearchResul ts", , , "text24 Like *" & filter1 & "*"

Field text24 is the field on teh results form that I am trying to pattern
match on.

Thanks.

Mike
m charney at dunlap hospital dot org
Apr 3 '06 #1
7 2760
You need to delimit your parameter. I am guessing that it is a text
param so you delimit it with single quotes '. Place a single quote
before the first '* and after the second *'

DoCmd.OpenForm "frmSearchResul ts", , , "text24 Like '*" & filter1 & "*'"
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 3 '06 #2
I think I got the command to work, except it opens a blank form with nothing
on it. None of the controls or text I have put on the form show up.

The command is:

DoCmd.OpenForm "frmSearchResul ts", , , Text24 Like "*" & filter1 & "*"

Text24 is the control on the results form that holds the Asset Tag #
filter1 is the data that the user enters on the search form to earch for an
asset tag #

I have checked the data in the table and the record is present. The asset
tag # is DMH10257. I tried to str(filter1) but it made no difference.

Does any one have an idea?

Mike

"Rich P" <rp*****@aol.co m> wrote in message
news:3u******** ******@news.usw est.net...
You need to delimit your parameter. I am guessing that it is a text
param so you delimit it with single quotes '. Place a single quote
before the first '* and after the second *'

DoCmd.OpenForm "frmSearchResul ts", , , "text24 Like '*" & filter1 & "*'"
Rich

*** Sent via Developersdex http://www.developersdex.com ***

Apr 3 '06 #3
Mike Charney wrote:
I think I got the command to work, except it opens a blank form with nothing
on it. None of the controls or text I have put on the form show up.

The command is:

DoCmd.OpenForm "frmSearchResul ts", , , Text24 Like "*" & filter1 & "*"

Text24 is the control on the results form that holds the Asset Tag #
filter1 is the data that the user enters on the search form to earch for an
asset tag #

I have checked the data in the table and the record is present. The asset
tag # is DMH10257. I tried to str(filter1) but it made no difference.

Does any one have an idea?

Mike

"Rich P" <rp*****@aol.co m> wrote in message
news:3u******** ******@news.usw est.net...
You need to delimit your parameter. I am guessing that it is a text
param so you delimit it with single quotes '. Place a single quote
before the first '* and after the second *'

DoCmd.OpenForm "frmSearchResul ts", , , "text24 Like '*" & filter1 & "*'"
Rich

*** Sent via Developersdex http://www.developersdex.com ***



Given the incomplete informmation provided, Rich's response was correct.

The WHERE clause needs to filter the data that is the RecordSource for
the form. Not the controls on the form. Is Text24 bound to a field in
the RecordSource? What is the name of the field that holds the Asset
Tag (hopefully, not Text24)?
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Apr 3 '06 #4
Say the user types in 2A3 for the Asset Tag. The proper format for
your command is:
DoCmd.OpenForm "frmSearchResul ts",,, "Text24 Like '*2A3*'"

That is: Text24 Like SingleQuote*2A3 *SingleQuote - All surrounded by
double-quotes.

Because you want to replace the FIlter string with a variable, it
becomes:

DoCmd.OpenForm "frmSearchResul ts",,, "Text24 Like '*" & filter1 & "*'"

That is:

"Text24 Like SINGLEQUOTE*Dou bleQuote & filter1 &
DoubleQuote*Sin gleQuoteDoubleQ uote

Chris Nebinger

Apr 3 '06 #5
Sorry for the incomplete information.

I did figure out the LIKE command but it seems that it returns no records
when I enter a number, like 257. The asset tag field holds DMH10257. I try
to search by 257 and I get no records using the LIKE command. The DMH part
of the field never changes, just the number.

The command I am using is:

DoCmd.OpenForm "frmSearchResul ts", , , assettag Like "*" & filter1 & "*"

I did have text24 instead of asset tag and I figured out that text24 was a
control that was not bound to a field. I fixed it but it will not return any
records. I also tried using the ' (single quote) mark but when I do I
receive a popup box asking me to type in data for the assettag field.

I guess I don't understand why the LIKE command doesn't work in the where
clause in an mdb file.

<ch************ @gmail.com> wrote in message
news:11******** *************@j 33g2000cwa.goog legroups.com...
Say the user types in 2A3 for the Asset Tag. The proper format for
your command is:
DoCmd.OpenForm "frmSearchResul ts",,, "Text24 Like '*2A3*'"

That is: Text24 Like SingleQuote*2A3 *SingleQuote - All surrounded by
double-quotes.

Because you want to replace the FIlter string with a variable, it
becomes:

DoCmd.OpenForm "frmSearchResul ts",,, "Text24 Like '*" & filter1 & "*'"

That is:

"Text24 Like SINGLEQUOTE*Dou bleQuote & filter1 &
DoubleQuote*Sin gleQuoteDoubleQ uote

Chris Nebinger

Apr 4 '06 #6
Mike Charney wrote:
Sorry for the incomplete information.

I did figure out the LIKE command but it seems that it returns no records
when I enter a number, like 257. The asset tag field holds DMH10257. I try
to search by 257 and I get no records using the LIKE command. The DMH part
of the field never changes, just the number.

The command I am using is:

DoCmd.OpenForm "frmSearchResul ts", , , assettag Like "*" & filter1 & "*"

I did have text24 instead of asset tag and I figured out that text24 was a
control that was not bound to a field. I fixed it but it will not return any
records. I also tried using the ' (single quote) mark but when I do I
receive a popup box asking me to type in data for the assettag field.

I guess I don't understand why the LIKE command doesn't work in the where
clause in an mdb file.

It's not going to work if you don't enclose the WHERE clause in quotes.
If assettag is a field in the recordsource for the form and filter1
contains your target value, such as 257, this syntax will work.

DoCmd.OpenForm "frmSearchResul ts", , , "assettag Like ""*" & filter1 & "*"""

(that was all on one line)

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Apr 4 '06 #7
Thanks for everyones help.

I have it working.

Mike

"Randy Harris" <pl****@send.no .spam> wrote in message
news:rU******** ***********@new ssvr21.news.pro digy.com...
Mike Charney wrote:
Sorry for the incomplete information.

I did figure out the LIKE command but it seems that it returns no records
when I enter a number, like 257. The asset tag field holds DMH10257. I
try to search by 257 and I get no records using the LIKE command. The DMH
part of the field never changes, just the number.

The command I am using is:

DoCmd.OpenForm "frmSearchResul ts", , , assettag Like "*" & filter1 & "*"

I did have text24 instead of asset tag and I figured out that text24 was
a control that was not bound to a field. I fixed it but it will not
return any records. I also tried using the ' (single quote) mark but when
I do I receive a popup box asking me to type in data for the assettag
field.

I guess I don't understand why the LIKE command doesn't work in the where
clause in an mdb file.

It's not going to work if you don't enclose the WHERE clause in quotes. If
assettag is a field in the recordsource for the form and filter1 contains
your target value, such as 257, this syntax will work.

DoCmd.OpenForm "frmSearchResul ts", , , "assettag Like ""*" & filter1 &
"*"""

(that was all on one line)

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.

Apr 4 '06 #8

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

Similar topics

105
5148
by: Peter Hickman | last post by:
Well after all this discussion it would appear that a 'Python like' language has appeared => Prothon. http://www.prothon.org/index.html Very alpha, sort of like Python (if you consider the indenting is what makes Python unique) and sort of Ruby in its use of prefixes to define scoping etc (although there is no reference to this trait being borrowed from Ruby). It also quotes Self as being an influence.
1
27460
by: mlke | last post by:
I would like to select the top 10 record from a table? How can I do it? In MS SQL, it's easy using select top 10 from table1. But in oracle database, I can't use top, anyone have any suggestions? Thanks!
4
2041
by: Aaron W. West | last post by:
Timings... sometimes there are almost too many ways to do the same thing. The only significant findings I see from all the below timings is: 1) Integer math is generally fastest, naturally. Bigint math isn't much slower, for integers that all fit within an integer. 2) Converting float to varchar is relatively slow, and should be avoided if possible. Converting from integer to varchar or varchar to int is several times faster.
4
25642
by: Tom Walker | last post by:
I cannot get the WHERE statement to work correctly unless I use a literal with the LIKE. I want to use a working storage data name so that I can vary the WHERE statement. Example that works: WHERE DSNAME LIKE 'ABC%' Example that does not work:
3
1856
by: Sean Shanny | last post by:
To all, We are running postgresql 7.4.1 on an G5 with dual procs, OSX 10.3.3 server, 8GB mem, attached to a fully configured 3.5TB XRaid box via fibre channel. I think we have run into this issue before but I thought the code was fixed. :-( I have the following SQL:
26
17189
by: GreatAlterEgo | last post by:
Hi, This is my query which is embedded in a COBOL program. EXEC SQL SELECT DATE, AGE, DURATION, AMT INTO :LDATE, :L.AGE, :L.DURATION, :L.AMT FROM TAB1 WHERE CODE = :KEY.CODE AND SET = :KEY.SET AND DATE <= :KEY.DATE
5
5095
by: davehansen22 | last post by:
Is there a way to generate a MySQL WHERE clause from a search string like this: "(dave OR hansen) php programmer" I would want to use the generated MySQL clause against a "memo" type field. I searched but apparently I'm not using the right keywords.
2
3901
by: boa sema | last post by:
Way back when, and at least in version 7 IIRC, the query optimizer gave up when the where clause in a statement contained more than 4 search conditions. Does anyone know if such a limitation still exist in MS SQL 2005? The BOL seems to be silent on the issue. Boa
1
3742
by: john | last post by:
I'm trying to build a LINQ expression that will use a dynamic construction of a LIKE statement in the WHERE clause, it would look something like this in SQL: WHERE TaskGroup Like "*00*" OR TaskGroup Like "*20*" It would be many variations on the above.
4
1733
by: Bernard Dhooghe | last post by:
Table definition: CREATE TABLE "SCHEMA1 "."X2" ( "C1" CHAR(20) NOT NULL , "C2" CHAR(10) NOT NULL , "C3" CHAR(30) NOT NULL GENERATED ALWAYS AS (C1|| C2) ) IN "USERSPACE1" ; -- DDL Statements for primary key on Table "SCHEMA1 "."X2"
0
8238
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
8174
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
8478
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
7164
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
6111
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
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
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
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
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.