CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Location
    the sticks
    Posts
    6

    Creating Search fuction

    In my database, I have a Troubleshooting table that contains frequently asked questions and their corresponding answers.

    What I've been asked to create is a search form where the user can type in part of a question, a keyword, or a phrase and all the questions in the Troubleshooting table that contain that bit of text will come up. The user can then double click on the question they want and the answer will come up.

    I can handle the double click code. I don't know how to create a search that will look at parts of the text.

    Anyone have any ideas?

    Crystal

  2. #2
    Join Date
    Mar 2002
    Posts
    92
    Try looking up "LIKE" as a SQL keyword, that should get you started.

  3. #3
    Join Date
    Aug 1999
    Posts
    28

    Smile

    You can also try the InStr function.

    You could loop through each question listed in your database with the InStr function.

    For example -

    Dim Pos As Integer 'Position found in String
    Dim YourString As String 'The value you are searching for

    Do Until RecordSet.EOF
    Pos = InStr(1, RecordSet![Field], YourString)
    If Pos <> 0 Then ' Value was found
    ListBox.AddItem RecordSet![Field]
    End If
    Pos = 0 'reset Pos to 0
    RecordSet.MoveNext
    Loop

    The above would add each question to the listbox where the string value you were searching for was found.

    The above uses DAO

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured