search query from a button in a form

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

Guest

I have created a button in a form that will be used to search from a table.
I have three different queries made to search from that table. When I push
the button to run the macro which in turn runs the 3 individual queries, it
just creates the results in 3 individual windows. I would like it to save
the results all in one window, how can I do this? Thanks much in advance!
 
Ok that makes sense. THen is there anyway to combine the queries so that I
can get only one result?
 
If it is just one table, you should be able to just write one query with all
the criteria combined from the 3. Maybe if you post the SQL from the
queries, we can have a look.

If you are not sure how to do that, just open a query in design mode,
switch to SQL view and copy/paste it.

Send all 3
 
Here is the SQL data for the query:
SELECT tbl_Standards.[Standard_ #], tbl_Standards.Chemical_name,
tbl_Standards.[Keyword 1], tbl_Standards.[Keyword 2], tbl_Standards.[Keyword
3]
FROM tbl_Standards
WHERE (((tbl_Standards.[Keyword 1])=[Enter keyword])) OR
(((tbl_Standards.[Keyword 2])=[Enter keyword])) OR (((tbl_Standards.[Keyword
3])=[Enter keyword]));

Note: the SQL data for the other two queries is identical...I want to be
able to search the same table that contains three columns with keywords in
each (some columns may contain the same words but for different items) and I
wanted to have the opportunity to search for three different words if I so
chose to, or just one, or two. Does this make sense?
Thank you for your help!
 
If what you are saying is you want to be able to search for multiple values
in Keyword 1 and multiple values in Keyword 2, and also Keyword 3. you can
style it this way. The only downside is whomever has to do the entry, has to
know how to do it correctly. You can us the IN predicate:

WHERE (((tbl_Standards.[Keyword 1]) IN([Enter keyword]))) OR
(((tbl_Standards.[Keyword 2]) IN([Enter keyword]))) OR
(((tbl_Standards.[Keyword
3])IN([Enter keyword])));

To enter it correctly, the values must be separated by commas. text values
need to be enclosed in quotes:

"Fred", "Joe", "Alvin", "Dan"

Dates in #

#8/23/2007#, #9/13/2007#, #5/25/2007#

Numbers need no delimiter

8,15, 202, 64
--
Dave Hargis, Microsoft Access MVP


wspintern said:
Here is the SQL data for the query:
SELECT tbl_Standards.[Standard_ #], tbl_Standards.Chemical_name,
tbl_Standards.[Keyword 1], tbl_Standards.[Keyword 2], tbl_Standards.[Keyword
3]
FROM tbl_Standards
WHERE (((tbl_Standards.[Keyword 1])=[Enter keyword])) OR
(((tbl_Standards.[Keyword 2])=[Enter keyword])) OR (((tbl_Standards.[Keyword
3])=[Enter keyword]));

Note: the SQL data for the other two queries is identical...I want to be
able to search the same table that contains three columns with keywords in
each (some columns may contain the same words but for different items) and I
wanted to have the opportunity to search for three different words if I so
chose to, or just one, or two. Does this make sense?
Thank you for your help!

Klatuu said:
If it is just one table, you should be able to just write one query with all
the criteria combined from the 3. Maybe if you post the SQL from the
queries, we can have a look.

If you are not sure how to do that, just open a query in design mode,
switch to SQL view and copy/paste it.

Send all 3
 
That is pretty close...essentially I want to be able to search for a text
word say "opiate" that may appear in Keyword 1, Keyword 2, and/or Keyword 3
column and I want to view all of the results which I have been able to do.
However, the problem lies that I want to be able to have the ability to
search for a second and third word say "sedative" and "hallucinogen" which
also appears in Keyword 1, Keyword 2, and/or Keyword 3 columns and have all
of the results appear on one table. With the SQL data you provided I am able
to search for one word and get results however when I search for two or three
words for some reason, whatever "text" I type into the search box whether or
not its even a word contained in the columns it just enters that word in
EVERY blank for that column in the results (for example if I type the word
"opiate" which isnt in the keyword 3 column it replaces everything in that
column with the word opiate). So I am just not really sure what to do and if
what I want to acheive is possible??
Thanks for your help in all of this frustration!

Klatuu said:
If what you are saying is you want to be able to search for multiple values
in Keyword 1 and multiple values in Keyword 2, and also Keyword 3. you can
style it this way. The only downside is whomever has to do the entry, has to
know how to do it correctly. You can us the IN predicate:

WHERE (((tbl_Standards.[Keyword 1]) IN([Enter keyword]))) OR
(((tbl_Standards.[Keyword 2]) IN([Enter keyword]))) OR
(((tbl_Standards.[Keyword
3])IN([Enter keyword])));

To enter it correctly, the values must be separated by commas. text values
need to be enclosed in quotes:

"Fred", "Joe", "Alvin", "Dan"

Dates in #

#8/23/2007#, #9/13/2007#, #5/25/2007#

Numbers need no delimiter

8,15, 202, 64
--
Dave Hargis, Microsoft Access MVP


wspintern said:
Here is the SQL data for the query:
SELECT tbl_Standards.[Standard_ #], tbl_Standards.Chemical_name,
tbl_Standards.[Keyword 1], tbl_Standards.[Keyword 2], tbl_Standards.[Keyword
3]
FROM tbl_Standards
WHERE (((tbl_Standards.[Keyword 1])=[Enter keyword])) OR
(((tbl_Standards.[Keyword 2])=[Enter keyword])) OR (((tbl_Standards.[Keyword
3])=[Enter keyword]));

Note: the SQL data for the other two queries is identical...I want to be
able to search the same table that contains three columns with keywords in
each (some columns may contain the same words but for different items) and I
wanted to have the opportunity to search for three different words if I so
chose to, or just one, or two. Does this make sense?
Thank you for your help!

Klatuu said:
If it is just one table, you should be able to just write one query with all
the criteria combined from the 3. Maybe if you post the SQL from the
queries, we can have a look.

If you are not sure how to do that, just open a query in design mode,
switch to SQL view and copy/paste it.

Send all 3
--
Dave Hargis, Microsoft Access MVP


:

Ok that makes sense. THen is there anyway to combine the queries so that I
can get only one result?

:

Has to be one query to get one result.
--
Dave Hargis, Microsoft Access MVP


:

I have created a button in a form that will be used to search from a table.
I have three different queries made to search from that table. When I push
the button to run the macro which in turn runs the 3 individual queries, it
just creates the results in 3 individual windows. I would like it to save
the results all in one window, how can I do this? Thanks much in advance!
 
Back
Top