Is there an easier way of writing this in a query

bearcub

Well-known Member
Joined
May 18, 2005
Messages
625
Office Version
  1. 365
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
I have a number of members that I need to exclude from a particular query. What I did was to have a string of Not Like Statements in the criteria section of the query to exclude these members from the query. Is there another way to do this in access?

This is the what I presently have and it works. I just wonder if there is another way of doing this:

Not Like "Elana Davidson" And Not Like "Dean E. Vogel" And Not Like "John C. Stocks" And Not Like "Joe Nuñez" And Not Like "Becky Pringle" And Not Like "Dr. Theresa Montaño" And Not Like "lily*" And Not Like "Princess R. Moss" And Not Like "Eric C. Heins" And Not Like "Mike Myslinski"

Thank you for your help,

Michael
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

james_lankford

Well-known Member
Joined
Jan 11, 2009
Messages
1,178
Code:
where 
(
  (
    not in ( 
      'Elana Davidson', 
      'Dean E. Vogel', 
      'John C. Stocks', 
      'Joe Nuñez', 
      'Becky Pringle', 
      'Dr. Theresa Montaño', 
       'Princess R. Moss', 
      'Eric C. Heins', 
      'Mike Myslinski' 
    ) 
  )
  and 
  (
    not like 'lily*'
  )
)
 

bearcub

Well-known Member
Joined
May 18, 2005
Messages
625
Office Version
  1. 365
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
Thank you. Is this what you've written here in SQL or in the design view of the query. If this in in SQL, how would I write this in the actual query itself.

Michael
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,950
Office Version
  1. 365
Platform
  1. Windows
For queries, in addition to Design View, Access has has SQL View. As long as what you are trying to do can be represented in Design View, you can bounce back and forth between these two views (certain types of queries, like Union queries, can only be seen in SQL View). So you could add this criteria in either View.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,961
Messages
5,599,061
Members
414,281
Latest member
Engjamal2021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top