Creating a search box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a database with one catagory labeled "Keywords". A single entry may
have a string such as "Rodeo; Gary; Magazine" (identifiers that we use to
catalog projects). Is there a way to create a search feature that would
allow me to search for "Magazine" so that all entries that have that as a key
word would appearor be highlighted (like a regular CTRL+F function). If
possible - what coding would I use?
 
Hi Holly,
We have to dostonguish 2 case
If you have just a table and you just wanna do a query that extract the
records with, for example magazine, you can do that putting on the field
keywords the instr function and as criteria <>0
instr(keywords;"string you are searching")

If you have a form based on the table that contains the data you can do that:
let's assume that the table is called datatable, the form dataform and the
text box where you write the string you are searching for src_box

on click of the search button that you wanna add put this code

forms!dataform.form.recordsource="select * from datatable where
instr(keywords,'" & src_box & "')<>0"
form.requery

In this way the recordsource of the form will be limited to the records
containing the string you are searching

HTH Paolo
 
Holly said:
I have a database with one catagory labeled "Keywords". A single entry may
have a string such as "Rodeo; Gary; Magazine" (identifiers that we use to
catalog projects). Is there a way to create a search feature that would
allow me to search for "Magazine" so that all entries that have that as a key
word would appearor be highlighted (like a regular CTRL+F function). If
possible - what coding would I use?


You can use a criteria for the keywords field in a query:

SELECT Title
FROM table
WHERE Keywords Like "*" & [Enter search word] & "*"

BUT, because the keywords field is in violation of the rules
of database Normalization, searching for anything much
beyond that will be at best a mess and at worst impossible.
 
dear cohen

your form that you reference below is perfevt for what i have been looking
for, but i have a couple of questions, can the code be altered to seach any
field with in the table that is attached to the form?

and can it be used to add the find next and find previous command
 
Back
Top