-
May 31st, 2002, 08:46 AM
#1
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
-
May 31st, 2002, 08:49 AM
#2
Try looking up "LIKE" as a SQL keyword, that should get you started.
-
May 31st, 2002, 03:16 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|