filtering subform using textbox

Posted on 2008-11-04
Last Modified: 2013-11-28
I have a main/subform in an Access 2007 db and am using
Forms![MainForm]![SubForm].Form.FilterOn = False
Forms![MainForm]![SubForm].Form.Filter = "[FieldtoFilter] = '" & Me.[txtFilterRecords].Text & "'"
Forms![MainForm]![SubForm].Form.FilterOn = True
to filter the subform via the textbox onChange event.  However, this only displays a record if there is an exact match, e.g. to display the record with "Hello World" in the FieldtoFilter I have to enter the whole "Hello World", I can't just put in "Hello" and have the filter display the matching record(s) (where matching would mean that the field either contains "Hello" (best solution) or begins with "Hello").  I prefer to do this via a filter rather than a new query.
Question by:luusac
    LVL 13

    Accepted Solution

    Forms![MainForm]![SubForm].Form.Filter = "(([lastname] LIKE '*" & Me.[txtFilterRecords].Text & "*'))"

    LVL 13

    Expert Comment

    Forms![MainForm]![SubForm].Form.Filter = "(([lastname] LIKE '*" & Me.[txtFilterRecords] & "*'))"

    Author Comment

    yes, this did the trick, many thanks

    Author Closing Comment

    many thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    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.

    794 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