• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

Access Select Criteria with Wildcards

I would like to select two or more criteria, in Query Design View, using two or more criteria.

For example:

1. Medicare
2. Managed Medicare
3. Medicaid
5. Medicaid Out of State

I have attempted using a Wildcard, in the Criteria screen, where I use *Medicare and *Medicaid, in order to retrieve all these records.

Like "Medicaid" Or Like "Medicaid" - did not work either.

Please offer suggestions, with what to enter in the "Criteria" section of the Query Design View Table.

Thanks.
0
tahirih
Asked:
tahirih
  • 6
  • 4
  • 3
2 Solutions
 
Anthony PerkinsCommented:
Using MS Access:
YourColumn LIKE "*Medicare" Or YourColumn Like "*Medicaid"

Using ADO:
YourColumn LIKE "%Medicare" Or YourColumn Like "%Medicaid"
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Example:

SELECT Table1.*, Table1.FIELD2
FROM Table1
WHERE (((Table1.FIELD1)="Medicare" Or (Table1.FIELD1)="Medicaid"));


mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
minor correction:

SELECT Table1.*
FROM Table1
WHERE (((Table1.FIELD1)="Medicare" Or (Table1.FIELD1)="Medicaid"));

mx
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
tahirihAuthor Commented:
This did not work.

In the "Criteria" section, I place

Like "%Medicare" OR Like "%Medicaid"

Please also not that the Medicare or the Medicaid does not always have to be first in the string value. Therefore, please allow flexibility for the location of these two workds within the string

Thanks
0
 
tahirihAuthor Commented:
In this instance, please how I would add this into "Criteria" in Query Design View. Thanks.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
can you post the SQL from the query design you have now ?

mx
0
 
Anthony PerkinsCommented:
>>This did not work.<<
Huh?  This is meaningless.  
1.  Did you get an error.  If so, what was the error.
2. Where the results not what you wanted, if not what were the results output and what were the desired results.
3. Did smoke come out of your monitor.

>>In the "Criteria" section, I place

Like "%Medicare" OR Like "%Medicaid"<<
Since you are obviously not using ADO why are you using %?
0
 
tahirihAuthor Commented:
Ok, I have gotten it to work partially myself. The following works in the "Criteria" box in Query Design:

Like "*Medicare*" Or Like "*Medicaid*"

So, I am retrieving all records that have these anywhere in the cell. However, I want o exclude anythign that says "Railroad Medicare" from this subset list.

Please advise.

Thanks
0
 
Anthony PerkinsCommented:
>>I have gotten it to work partially myself. <<
Yeah, right. That was my suggestion

>>However, I want o exclude anythign that says "Railroad Medicare" from this subset list.<<
You need an And condition.  As in AND <> "Railroad Medicare"
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Here is another way:

SELECT Table1.*
FROM Table1
WHERE (((InStr(1,[FIELD1],"Medicare")>0)=True)) OR (((InStr(1,[FIELD1],"Medicaid")>0)=True));


mx
0
 
tahirihAuthor Commented:
Database, I have request the question to be re-opened, since I awarded points pre-maturely, before seeing your last postin. Thanks.
0
 
tahirihAuthor Commented:
AcPerkins, what I did on my own was to include the second * so that the placement of Medicare/Medicaid cound be anywhere in the string.

Thanks.
0
 
tahirihAuthor Commented:
Thanks.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now