473,499 Members | 1,689 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 "frmSearchResults", , , "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 2752
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 "frmSearchResults", , , "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 "frmSearchResults", , , 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.com> wrote in message
news:3u**************@news.uswest.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 "frmSearchResults", , , "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 "frmSearchResults", , , 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.com> wrote in message
news:3u**************@news.uswest.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 "frmSearchResults", , , "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 "frmSearchResults",,, "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 "frmSearchResults",,, "Text24 Like '*" & filter1 & "*'"

That is:

"Text24 Like SINGLEQUOTE*DoubleQuote & filter1 &
DoubleQuote*SingleQuoteDoubleQuote

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 "frmSearchResults", , , 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*********************@j33g2000cwa.googlegro ups.com...
Say the user types in 2A3 for the Asset Tag. The proper format for
your command is:
DoCmd.OpenForm "frmSearchResults",,, "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 "frmSearchResults",,, "Text24 Like '*" & filter1 & "*'"

That is:

"Text24 Like SINGLEQUOTE*DoubleQuote & filter1 &
DoubleQuote*SingleQuoteDoubleQuote

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 "frmSearchResults", , , 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 "frmSearchResults", , , "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*******************@newssvr21.news.prodigy. 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 "frmSearchResults", , , 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 "frmSearchResults", , , "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
5079
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...
1
27438
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?...
4
2029
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....
4
25569
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: ...
3
1841
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...
26
17157
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...
5
5085
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. ...
2
3894
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...
1
3734
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...
4
1728
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...
0
7134
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
7014
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
7180
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,...
1
6905
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...
0
5485
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,...
1
4921
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...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
311
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...

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.