Results 1 to 4 of 4
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    Access VBA Filter Syntax


    I am trying to use Access VBA to apply a simple string Filter to my Form. My code includes the following syntax:

    Code:
    CONTACT_LASTNAME like '%" & strLastName & "%'"
    I am looking to execute a Contains filter. Is the proper syntax? Sometimes it seems to work, but it is not consistent in which records it is filtering.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Try * instead of %.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Now I get no results..

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Curious, as in the form filter I'd expect *; % is used in ADO. Can you post a sample db that exhibits the inconsistent behavior?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using IN Syntax in a Filter
    By ybg1 in forum Access
    Replies: 6
    Last Post: 10-31-2011, 02:59 PM
  2. Access version syntax help, looping
    By shubhamgandhi in forum Programming
    Replies: 8
    Last Post: 07-21-2011, 02:35 PM
  3. Access SQL syntax Reference other tables
    By Lorlai in forum Queries
    Replies: 3
    Last Post: 06-08-2011, 05:21 PM
  4. Syntax Error in Query Expression on filter
    By alaric01 in forum Forms
    Replies: 1
    Last Post: 10-14-2010, 07:23 AM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums