Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wildcard Searching... (A2002)

    Hello All,
    I am trying to create a wild card search of a table, the outcome filling a subform. Here is what I have for the command button:
    ----------------------------------------------------
    Dim strT28 As String, strSearch As String

    strT28 = Me.Text28
    strSearch = "*" & strT28 & "*"
    Me.[sbfSNSearch].Form.RecordSource = "select * from equip where equip.equip_sn Like " & strSearch
    ----------------------------------------------------

    I have a control that I use to input some text. After that I click a command button that executes what is listed above. I can run a regular query using "*" on either side of the text I am looking for and it works. However, when I try to execute this using VBA, it gives a syntax error.

    Amy help would be appreciated.

    Thanks,
    Mark

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wildcard Searching... (A2002)

    The search string must be enclosed in quotes. One way to get quotes into a quoted string is to concatenate with Chr(34).

    Me.[sbfSNSearch].Form.RecordSource = "select * from equip where equip.equip_sn Like " & Chr(34) & strSearch & Chr(34)

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard Searching... (A2002)

    Thanks Hans,
    I will give that a try

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •