Results 1 to 5 of 5
  1. #1
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125

    Wildcard Expressions in Search Field

    Is there a way to turn these off? Or is there a way to work around them. I have a search field that works fine except for when the field it is searching has a # in it.



    I realize that you can put brackets around it when you are searching and everything works fine but I'm trying to make it a little more user friendly so I was wondering if there is a way to disable the wildcard expressions and/or when the search field is entered, if it contains a #, replacing the text with whatever it was, except with [#] instead.

    My last resort might just be disallowing a special characters like #,?,* to be entered into the field that is being searched, but I'm not sure how to do this either. This is only if the first two options are not doable though.

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you can replace the # in search string to [#], for example, in your table you have "abcd#a234" in a record, user input search string "*#a2", then you change search string to "*[#]a2" (you may use use replace(SearchStr,"#","[#]") ), and you can find the record.

    Same for ?, *

  3. #3
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    I think this is on the right track for what I want, but I'm still having some problems understanding it / implementing it. Here's what I have so far:

    Private Sub cboProjectSearch_AfterUpdate()
    Dim LResult As String
    LResult = Replace(cboProjectSearch, "#", "[#]")
    Me.txtProjectName.SetFocus
    DoCmd.FindRecord Me.cboProjectSearch, acEntire
    End Sub

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you did not use the LResult in the search command.

    Please change
    DoCmd.FindRecord Me.cboProjectSearch, acEntire
    to
    DoCmd.FindRecord LResult, acEntire

  5. #5
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    Ah hah! There it is, thanks a bunch Weekend.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-31-2010, 08:57 PM
  2. Search a Number in Database Field
    By julia_877 in forum Programming
    Replies: 3
    Last Post: 08-06-2010, 01:24 PM
  3. Creating a Search Field
    By SKUPenn in forum Programming
    Replies: 1
    Last Post: 01-28-2010, 08:39 PM
  4. Parameter Query & Wildcard
    By Rick West in forum Queries
    Replies: 8
    Last Post: 12-29-2009, 10:54 AM
  5. Search All Field
    By robbiebrown34 in forum Access
    Replies: 0
    Last Post: 05-17-2007, 09:40 AM

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