Results 1 to 3 of 3
  1. #1
    bcournoyer is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2023
    Posts
    9

    Like Operator not Working in OpenForm Command

    In the code below I am trying to lookup a part number by a partial match (ex: find CH PS-1 by searching for PS). If I change LIKE to = and remove the wildcards I can successfully search for the entire part number. Can anyone see my error?
    Code:
    Private Sub btnPartLookup_Click()
    
    
        Dim myF As Form
        Set myF = Forms("frmNav")
        DoCmd.OpenForm "frmPartList", acNormal, , "[PARTNO] LIKE '%" & myF!txtCatNum & "%'"
        Set myF = Nothing
    
    
    End Sub


  2. #2
    bcournoyer is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2023
    Posts
    9
    Solved my own post. Exchanged * wildcards for % wildcards and it worked.

  3. #3
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    % wildcards are the SQL-ANSI standards, * are Access and Excel.

    You can make Access use the ANSI version if you tick the appropriate box in the File¬ Options ¬ Object Designers section.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 30
    Last Post: 06-11-2020, 07:26 AM
  2. Replies: 2
    Last Post: 02-02-2018, 01:50 PM
  3. Replies: 11
    Last Post: 08-22-2017, 05:50 PM
  4. Replies: 2
    Last Post: 01-26-2017, 03:53 PM
  5. OpenForm in subform not working
    By eyuen in forum Forms
    Replies: 3
    Last Post: 11-10-2010, 12:03 PM

Tags for this Thread

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