How do I search by text in Access?

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

Guest

I'm using Access 2000 and I am creating a Question and Answer database. I
have created search functions (a form) by topic and product via a subform.
What I need to do is create the ability for a user to search via text. For
instance, on opening the database, a user can select "search by text" option
and can then type their own question. The end result would be a list of all
questions and answers matching the keyword or text that the user entered.
 
Hi, Heidi.

Use the Like operator in conjunction with the * wildcard. Create a form
with a textbox on it for the user to enter the keyword and a command button
to open a query which references the textbox. Assuming you want to search
both the question and the answer fields:

SELECT YourTable.*
FROM YourTable
WHERE (((YourTable.Question) Like "*" & [Forms]![YourForm]![YourTextbox] &
"*")) OR (((YourTable.Answer) Like "*" & [Forms]![YourForm]![YourTextbox] &
"*"));

Hope that helps.
Sprinks
 
Thanks, I'll try that.


Sprinks said:
Hi, Heidi.

Use the Like operator in conjunction with the * wildcard. Create a form
with a textbox on it for the user to enter the keyword and a command button
to open a query which references the textbox. Assuming you want to search
both the question and the answer fields:

SELECT YourTable.*
FROM YourTable
WHERE (((YourTable.Question) Like "*" & [Forms]![YourForm]![YourTextbox] &
"*")) OR (((YourTable.Answer) Like "*" & [Forms]![YourForm]![YourTextbox] &
"*"));

Hope that helps.
Sprinks

Heidi @ uhc said:
I'm using Access 2000 and I am creating a Question and Answer database. I
have created search functions (a form) by topic and product via a subform.
What I need to do is create the ability for a user to search via text. For
instance, on opening the database, a user can select "search by text" option
and can then type their own question. The end result would be a list of all
questions and answers matching the keyword or text that the user entered.
 
I did what you said below, and it works when typing in either an exact
question, or a keyword. Is there any way to search if the entry in the Text
Box is 'contained' in either my question or answer fields? Is that what the
fomula below is already doing? There are just so many variances of how a
person can ask a question, I'm hoping to find a way work with that. For
example.
Question 1: How do I open a health savings account?
Current result: Pulls the right question, but the question asked is typed
exactly the same way in the database.
Question 2: How do I open and HSA account?
Current Result: the database doesn't pull anything.

Any way to resolve?

Thanks,
Heidi

Sprinks said:
Hi, Heidi.

Use the Like operator in conjunction with the * wildcard. Create a form
with a textbox on it for the user to enter the keyword and a command button
to open a query which references the textbox. Assuming you want to search
both the question and the answer fields:

SELECT YourTable.*
FROM YourTable
WHERE (((YourTable.Question) Like "*" & [Forms]![YourForm]![YourTextbox] &
"*")) OR (((YourTable.Answer) Like "*" & [Forms]![YourForm]![YourTextbox] &
"*"));

Hope that helps.
Sprinks

Heidi @ uhc said:
I'm using Access 2000 and I am creating a Question and Answer database. I
have created search functions (a form) by topic and product via a subform.
What I need to do is create the ability for a user to search via text. For
instance, on opening the database, a user can select "search by text" option
and can then type their own question. The end result would be a list of all
questions and answers matching the keyword or text that the user entered.
 
Back
Top