?
Solved

vba filter not working on OR

Posted on 2013-01-06
3
Medium Priority
?
223 Views
Last Modified: 2013-01-07
I have this filter :
Me.Form.Filter = "[Body type]<>'Estate' OR [body type]<>'MPV' OR [body type]<>'Hatchback' Or [body type]<>'Saloon' Or [body type]<>'Roadster'"

The syntax appears ok however i get records showing within the exclusions.

if i do this Me.Form.Filter = "[Body type]<>'Estate' it will exclude the group.
0
Comment
Question by:PeterBaileyUk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38750006
You can't use OR with <>
Try to change OR to AND

For example A <> 2 OR A <> 1 will always be true
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 2000 total points
ID: 38750430
As Alex said, you can change your ORs to ANDs, or you can use this:
Me.Form.Filter = "[Body type] NOT IN('Estate', 'MPV', 'Hatchback', 'Saloon', 'Roadster')"
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 38751343
nice solution thx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question