Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Wild Card For Filter Search


Message #1 by jmendez@k... on Tue, 23 Apr 2002 04:27:57
I'm trying to do a filter search on an access database where the field 
contains the value submitted from the form anywhere in the Access table 
field.

For instance, I have a field where values were entered in a variety of 
ways, such as name.  A name could be entered as John Smith or Smith, John, 
etc.  I want to find all the Smith's regardless of how it was typed in.

I can search for a wildcard at the end of the field:

       strCriteria = "prem-type LIKE '" & strRecord & "*'"
       objRS.Filter = strCriteria

But I am having difficulties adding the wildcard (*) at the beginning and 
ending of the field, where there would be an asterisk at the front and 
back of strRecord above.

Can someone please help me with the syntax.

Thank You.
Message #2 by "Ethan Selzer" <ethanselzer@a...> on Mon, 22 Apr 2002 20:38:25 -0700
Although Access uses the *  and _ to represent  wildcards I think ADO uses %
and _ . So your code would look something like:

strCriteria = "prem-type LIKE '%" & strRecord & "%'"

Ethan

-----Original Message-----
From: jmendez@k... [mailto:jmendez@k...]
Sent: Tuesday, April 23, 2002 4:28 AM
To: Access ASP
Subject: [access_asp] Wild Card For Filter Search

I'm trying to do a filter search on an access database where the field
contains the value submitted from the form anywhere in the Access table
field.

For instance, I have a field where values were entered in a variety of
ways, such as name.  A name could be entered as John Smith or Smith, John,
etc.  I want to find all the Smith's regardless of how it was typed in.

I can search for a wildcard at the end of the field:

       strCriteria = "prem-type LIKE '" & strRecord & "*'"
       objRS.Filter = strCriteria

But I am having difficulties adding the wildcard (*) at the beginning and
ending of the field, where there would be an asterisk at the front and
back of strRecord above.

Can someone please help me with the syntax.

Thank You.


  Return to Index