Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I let a user search all records for a particular word please?

Status
Not open for further replies.

meeble

Programmer
Sep 24, 2002
137
0
0
GB
Hello,

I want to have a form with a button on it. If the user presses the button, it opens up a pop up box and asks the user to enter a word. When they enter this word, it brings up a list of all the records with that word in it (in any field).

Is this possible?

Cheers

James
 
hi James,

this is possible. something like this

dim rst as recordset, db as database
dim sWord as string

sWord = InputBox("search word")

sWord = "*" & SWord & "*"

set rst = db.openrecordset("SELECT * FROM WordTable WHERE WordField LIKE '" & sWord & "'")

it is also possible to achieve this via a query where you use the inputbox as the criteria.

regards roltrap
 
Hello, thanks for your help. I tried to insert that code but couldn't get it to work. Maybe I'm putting it in the worng place. Where do I put it?

Cheers

James
 
ok, here some more information.

the code has to be put in the On_Click Event of the button.

If you want the filtered data displayed in a listbox like you said, the code will be like this:


dim sWord as string

sWord = InputBox("search word")

sWord = "*" & SWord & "*"
lstWord.RowSource = "SELECT
.[Word] FROM
where
.[Word] LIKE '" & sWord & "'"


hope this makes it clearer

Roltrap

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top