Results 1 to 3 of 3
  1. #1
    jhs326 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    2

    Using Like in a filter to search for any character

    I have a form for searching with unbound text fields. There is a subform that gets its data from a query. What I have now works for searching for the first letter in each field. I have made queries in the past using Like "*"+[control]+"*" but cannot figure out how to translate this into VBA with the code I am using now.



    If Me.txtcustname > "" Then
    varWhere = varWhere & "[name] LIKE """ & Me.txtcustname & "*"" AND "
    End If


    I need to do something with the red portion but cannot figure out what. Any help would be greatly appreciated.

    Thanks

  2. #2
    kenwarthen is offline Novice
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    2

    Using Like in a filter to search for any character

    I'm not real clear about what you're attempting to do, and what issues you're having but if you want to filter on any character you can use Like "[A-Z]". For example, a line from a routine in a module from one of my databases use the following lines to test for, among other things, the last character in a variable being an alpha character. Hope this helps. - Ken

    If (Left(strLgcyStorageBin, 1) = "W" Or Left(strLgcyStorageBin, 1) = "N") And (right(strLgcyStorageBin, 1) = "D") Then
    fGetKernelStorageType = "YL1"
    ElseIf (Left(strLgcyStorageBin, 1) = "3" And (right(strLgcyStorageBin, 1) Like "[A-Z]")) Then
    fGetKernelStorageType = "YL1"
    End If

  3. #3
    jhs326 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    2
    Thanks Ken, I just started pushing buttons over and over again until I finally got it to work. Ended up with this;

    varWhere = varWhere & "[first] Like """ & "*" + Me.txtcustname + "*" & "*"" AND "

    I was using an unbound form to search a query. The code I had was only searching the first character of the field. I needed to be able to enter any character in the unbound form and it find matching records in the query.

    Thanks for the reply I am sure I will need more help as I move along.

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

Similar Threads

  1. How to filter/search using a forum?
    By MediaCo in forum Access
    Replies: 3
    Last Post: 07-04-2011, 03:30 AM
  2. Query filter search
    By mseeker22 in forum Queries
    Replies: 6
    Last Post: 06-22-2011, 03:35 PM
  3. Database Search filter
    By dada in forum Programming
    Replies: 7
    Last Post: 08-19-2010, 12:42 AM
  4. search for "*" character
    By supernova122 in forum Access
    Replies: 2
    Last Post: 07-06-2009, 06:16 AM
  5. filter by the number of character
    By bangemd in forum Access
    Replies: 1
    Last Post: 06-30-2009, 10:33 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