Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Posts
    40

    Unanswered: wildcard function, how to do that

    hi. i have a little problem regarding this newbie code.

    here it is.

    Private Sub cmdSearch_Click()
    On Error GoTo Err_cmdSearch_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Search Engine"

    stLinkCriteria = "[Project] like " & Chr$(34) & Me![txtSearch] & "?*" & Chr$(34)
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_cmdSearch_Click:
    Exit Sub

    Err_cmdSearch_Click:
    MsgBox Err.Description
    Resume Exit_cmdSearch_Click

    End Sub


    When i input the few abc or full name in txtsearch, to return the records starting with a or b or ab or various combination, and full name as well.

    MY current seem not working at all.

    Please help.

    Thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Try your criteria string without the question mark. For example:
    Code:
    stLinkCriteria = "[Project] LIKE " & Chr$(34) & Me![txtSearch] & "*" & Chr$(34)
    You could also try and set up your criteria string this way:
    Code:
    stLinkCriteria = "[Project] LIKE " & Chr$(34) & Me![txtSearch] & "?*" & Chr$(34) & " OR [Project] LIKE " & Chr$(34) & Me![txtSearch] & "?" & Chr$(34)

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Jun 2004
    Posts
    40
    it WORK! keke..

    but the only problem is. when i input a, it is supposed to be return all the records starting with a. how come it return only one from all the records, starting with a letter ?

    Have i misuse the form somewhere else ???

  4. #4
    Join Date
    Jun 2004
    Posts
    40
    it WORK! keke..

    but the only problem is. when i input a, it is supposed to be return all the records starting with a. how come it return only one from all the records, starting with a letter ?

    Have i misuse the form somewhere else ???

    Quote Originally Posted by CyberLynx
    Try your criteria string without the question mark. For example:
    Code:
    stLinkCriteria = "[Project] LIKE " & Chr$(34) & Me![txtSearch] & "*" & Chr$(34)
    You could also try and set up your criteria string this way:
    Code:
    stLinkCriteria = "[Project] LIKE " & Chr$(34) & Me![txtSearch] & "?*" & Chr$(34) & " OR [Project] LIKE " & Chr$(34) & Me![txtSearch] & "?" & Chr$(34)

    .

  5. #5
    Join Date
    Nov 2003
    Posts
    1,487
    Hmmm...good question. Try this:

    stLinkCriteria = "[Project] LIKE '" & Me.txtSearch & "*'"

    This should work....

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  6. #6
    Join Date
    Jun 2004
    Posts
    40
    Hi cyberlynx.

    Hmm.. i have tried your code liao. basically it is same.

    But i know where the fault lie with me.. keke.. Misuse the design form.

    Thanks for help

Posting Permissions

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