filter with OR

Posted on 2011-04-26
Last Modified: 2012-05-11
I have a filter that works fine with one element but when I add a second it doesn't work.

right now I have a search text box in a main form that filters a subform based on the textbox in the subform called "SupplierCode". I also have a textbox called "SupplierName" and would like to apply the filter to both textboxes...filtering anything that contains either part of the "SupplierCode" OR the "SupplierName".

here is the simple filter that works:
Me.sbfrmEntitySearchSupplier.Form.Filter = "[SupplierCode] LIKE '*" & Me.search0 & "*'"
Me.sbfrmEntitySearchSupplier.Form.FilterOn = True

how would I do this?
Question by:Shawn
    LVL 119

    Accepted Solution

    try this

    Me.sbfrmEntitySearchSupplier.Form.Filter = "[SupplierCode] LIKE '*" & Me.search0 & "*' OR [SupplierName] LIKE '*" & Me.search0 & "*'"
    Me.sbfrmEntitySearchSupplier.Form.FilterOn = True

    Open in new window

    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    Try this:

    Me.sbfrmEntitySearchSupplier.Form.Filter = "[SupplierCode] LIKE *" & Chr(34) & Me.search0 & Chr(34) & "*" & " OR [SupplierName] LIKE *" & Chr(34) & Me.search0 & Chr(34) & "*"
    Me.sbfrmEntitySearchSupplier.Form.FilterOn = True

    LVL 1

    Author Comment

    thanks to both. gr8 solutions/ideas as always

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now