Microsoft Office Forums


Reply
Thread Tools Display Modes

Wildcard to filter form

 
 
DeVille
Guest
Posts: n/a
 
      02-18-2004, 10:13 PM
Hi I have this piece of code which uses an 'on-click'
event procedure on my form to filters my records. The
field is named 'Subject' and the code brings up a
dialogue box which I then type the first part of a
sentence and it finds all records which start with that
text. Eg if I type 'TH' it would bring back all records
that start with words like 'THE', 'THERE' or 'THAT' etc.
I would like to change the code so that it finds records
where the wild card is in the middle of the text. Eg if I
typed "OO' it would find 'BOOK' or 'SCHOOL' etc.
If any one can help me thanks in advance. see code
below

Let CurRecNo = Form.CurrentRecord
QryFld = " Subject "

Me.Filter = "[Subject] Like '" & InputBox("Enter
Subject") & "*'"
Me.FilterOn = True

 
Reply With Quote
 
 
 
 
Dan Artuso
Guest
Posts: n/a
 
      02-18-2004, 11:54 PM
Hi,
Try this:

Me.Filter = "[Subject] Like '*" & InputBox("Enter Subject") & "*'"
--
HTH
Dan Artuso, Access MVP


"DeVille" <(E-Mail Removed)> wrote in message news:12e5301c3f66c$72d2e2f0$(E-Mail Removed)...
> Hi I have this piece of code which uses an 'on-click'
> event procedure on my form to filters my records. The
> field is named 'Subject' and the code brings up a
> dialogue box which I then type the first part of a
> sentence and it finds all records which start with that
> text. Eg if I type 'TH' it would bring back all records
> that start with words like 'THE', 'THERE' or 'THAT' etc.
> I would like to change the code so that it finds records
> where the wild card is in the middle of the text. Eg if I
> typed "OO' it would find 'BOOK' or 'SCHOOL' etc.
> If any one can help me thanks in advance. see code
> below
>
> Let CurRecNo = Form.CurrentRecord
> QryFld = " Subject "
>
> Me.Filter = "[Subject] Like '" & InputBox("Enter
> Subject") & "*'"
> Me.FilterOn = True
>



 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      02-19-2004, 04:59 AM
On Wed, 18 Feb 2004 14:13:33 -0800, "DeVille"
<(E-Mail Removed)> wrote:

>I would like to change the code so that it finds records
>where the wild card is in the middle of the text. Eg if I
>typed "OO' it would find 'BOOK' or 'SCHOOL' etc.
>If any one can help me thanks in advance. see code
>below
>
>Let CurRecNo = Form.CurrentRecord
>QryFld = " Subject "
>
>Me.Filter = "[Subject] Like '" & InputBox("Enter
>Subject") & "*'"


A LIKE clause uses wildcards: * means "match any string of zero or
more characters", ? means "match any single character", # means "match
any digit", etc. So if you want any string of characters, followed by
a selected string, followed by any other characters you just need a *
before and after the subject:

"[Subject] Like '*" & InputBox("Enter Subject") & "*'"

If the user types in OO this will be expanded to

[Subject] LIKE '*OO*'

and will match as you requested.

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Me.Filter using wildcard in formula larochy Access Forms 2 02-25-2009 01:20 PM
Re: Advanced Filter - Wildcard Problem Debra Dalgleish Excel General 1 04-09-2008 03:35 AM
Wildcard Filter Issues Jahlu Access Forms 6 08-14-2007 01:17 PM
filter with wildcard JB Access Forms Coding 11 06-27-2006 01:52 PM
Wildcard Filter Code DeVille Access Forms 2 09-12-2003 05:10 AM


All times are GMT. The time now is 05:39 AM.
Microsoft Office Forums is not affiliated with Microsoft Corporation.


Welcome!
Welcome to the Microsoft Office Forums
 


Latest Threads
New user looking for shapes/templates
SargeUSMC (04-21-2014, 04:23 PM)

Mail Merging Content With High Quality
oleander (04-17-2014, 11:59 PM)

Aargh. What is this?
PeteJ (04-17-2014, 12:10 PM)

Word 2013 Insert Symbol (Not Responding)
tpthrshr (04-17-2014, 02:49 AM)

Can't save a large Word document
Josh (04-17-2014, 01:03 AM)