Me.Filter Query question

Posted on 2011-04-25
Last Modified: 2012-05-11
What am I doing wrong with the strFilter portion of this code.  I get the attached error everytime.
I am trying to filter the records to only get records with LIKE results in the column called Description.  In the test I was looking for the word GOD.

strFilter = "Description LIKE '" & strSearch '"
Me.Filter = strFilter
Me.FilterOn = True
 Error message Error message
Question by:sfn149
    LVL 75

    Expert Comment

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

    strFilter = "[Description] = " & Chr(34)  & strSearch & Chr(34)
    Me.Filter = strFilter
    Me.FilterOn = True

    LVL 47

    Accepted Solution

    or if you really mean 'GOD' imbedded anywhere within the [Description] field, then try:

    strFilter = "[Description] like '*" & strSearch & "*'"
    me.filter = strFilter
    me.FilterOn = true


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    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…
    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    729 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

    16 Experts available now in Live!

    Get 1:1 Help Now