Criteria in a Querie

T

Tdahlman

I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis
 
K

KARL DEWEY

Try this --
[Forms]![frm_Search]![Manufacturer] Or [Forms]![frm_Search]![Manufacturer]
Is Null
 
T

Tdahlman

That didn't quite work.
Right now I only have 2 of the criteria working so that I can figure this
out without changing 10 different things.

I have one called [Manufacturer] and one called [Width].

If I make the selection in for Width, but not Manufacturer then it shows me
all of the entries that I have without a filter. But if I only make a
selection for the Manufacturer then I don't get any results.

Any other suggestions?


KARL DEWEY said:
Try this --
[Forms]![frm_Search]![Manufacturer] Or [Forms]![frm_Search]![Manufacturer]
Is Null


Tdahlman said:
I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis
 
J

John W. Vinson

I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis

If you have ten optional criteria, try using "Query By Form" - either the
builtin one that comes with Access, or roll your own. See Tom Wickreath's
examples

QBF Examples
http://www.accessmvp.com/TWickerath/downloads/customdialogbox.zip


http://www.accessmvp.com/TWickerath/downloads/elements.zip


http://www.accessmvp.com/TWickerath/downloads/Chap08QBF.zip


http://www.seattleaccess.org/downloads.htm
 
K

KARL DEWEY

I tested with 2 and it worked.
Post the SQL of your query.

Tdahlman said:
That didn't quite work.
Right now I only have 2 of the criteria working so that I can figure this
out without changing 10 different things.

I have one called [Manufacturer] and one called [Width].

If I make the selection in for Width, but not Manufacturer then it shows me
all of the entries that I have without a filter. But if I only make a
selection for the Manufacturer then I don't get any results.

Any other suggestions?


KARL DEWEY said:
Try this --
[Forms]![frm_Search]![Manufacturer] Or [Forms]![frm_Search]![Manufacturer]
Is Null


Tdahlman said:
I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis
 
T

Tdahlman

I'm sorry but I'm not sure what that means.
taught myself everything I know in Access so the technical name for things
is not my strong suit.

KARL DEWEY said:
I tested with 2 and it worked.
Post the SQL of your query.

Tdahlman said:
That didn't quite work.
Right now I only have 2 of the criteria working so that I can figure this
out without changing 10 different things.

I have one called [Manufacturer] and one called [Width].

If I make the selection in for Width, but not Manufacturer then it shows me
all of the entries that I have without a filter. But if I only make a
selection for the Manufacturer then I don't get any results.

Any other suggestions?


KARL DEWEY said:
Try this --
[Forms]![frm_Search]![Manufacturer] Or [Forms]![frm_Search]![Manufacturer]
Is Null


:

I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis
 
K

KARL DEWEY

Open your query in design view, click on VIEW - SQL View, highlight all,
copy, and paste in a post.

Tdahlman said:
I'm sorry but I'm not sure what that means.
taught myself everything I know in Access so the technical name for things
is not my strong suit.

KARL DEWEY said:
I tested with 2 and it worked.
Post the SQL of your query.

Tdahlman said:
That didn't quite work.
Right now I only have 2 of the criteria working so that I can figure this
out without changing 10 different things.

I have one called [Manufacturer] and one called [Width].

If I make the selection in for Width, but not Manufacturer then it shows me
all of the entries that I have without a filter. But if I only make a
selection for the Manufacturer then I don't get any results.

Any other suggestions?


:

Try this --
[Forms]![frm_Search]![Manufacturer] Or [Forms]![frm_Search]![Manufacturer]
Is Null


:

I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis
 
J

John W. Vinson

I'm sorry but I'm not sure what that means.
taught myself everything I know in Access so the technical name for things
is not my strong suit.

Open the query in design view. Select View... SQL from the menu; a window will
open with a bunch of text (the *real* query, the query grid is just a tool to
make it easier to create SQL). Copy and paste the text to a message here.
 
T

Tdahlman

Here is the SQL:

SELECT tbl_Flooring.[EFD ID], tbl_Flooring.[Manuf Item Number],
tbl_Flooring.Manufacturer, tbl_Manufacturer.Manufacturer,
tbl_Flooring.Description, tbl_Flooring.[Sq Ft per Case], tbl_Flooring.[In
Stock], tbl_Flooring.[Weight per Sq Ft], tbl_Flooring.Species,
tbl_Flooring.Color, tbl_Flooring.Width, tbl_Width.Width,
tbl_Flooring.Thickness, tbl_Type.Type, tbl_Flooring.Finish, tbl_Flooring.[Top
Layer], tbl_Flooring.Grade, tbl_Flooring.Price, tbl_Flooring.Collection,
tbl_Flooring.Floatable, tbl_Flooring.Clickable, tbl_Flooring.Glueable,
tbl_Flooring.Nailable, tbl_Flooring.[On Special], tbl_Flooring.[Special
Price], tbl_Flooring.Comments, tbl_Flooring.DISCONTINUED
FROM tbl_Width INNER JOIN (tbl_Manufacturer INNER JOIN (tbl_Type INNER JOIN
tbl_Flooring ON tbl_Type.TypeID = tbl_Flooring.Type) ON
tbl_Manufacturer.ManufacturerID = tbl_Flooring.Manufacturer) ON
tbl_Width.WidthID = tbl_Flooring.Width
WHERE (((tbl_Flooring.Manufacturer)=[Forms]![frm_Search]![Manufacturer]) AND
((tbl_Flooring.Width)=[Forms]![frm_Search]![Width])) OR
((([Forms]![frm_Search]![Width]) Is Null And ([Forms]![frm_Search]![Width])
Is Null) AND (([Forms]![frm_Search]![Manufacturer]) Is Null)) OR
((([Forms]![frm_Search]![Manufacturer]) Is Null And
([Forms]![frm_Search]![Manufacturer]) Is Null));





KARL DEWEY said:
Open your query in design view, click on VIEW - SQL View, highlight all,
copy, and paste in a post.

Tdahlman said:
I'm sorry but I'm not sure what that means.
taught myself everything I know in Access so the technical name for things
is not my strong suit.

KARL DEWEY said:
I tested with 2 and it worked.
Post the SQL of your query.

:

That didn't quite work.
Right now I only have 2 of the criteria working so that I can figure this
out without changing 10 different things.

I have one called [Manufacturer] and one called [Width].

If I make the selection in for Width, but not Manufacturer then it shows me
all of the entries that I have without a filter. But if I only make a
selection for the Manufacturer then I don't get any results.

Any other suggestions?


:

Try this --
[Forms]![frm_Search]![Manufacturer] Or [Forms]![frm_Search]![Manufacturer]
Is Null


:

I have query with the criteria of multiple fields based on a form (i.e.
[Forms]![frm_Search]![Manufacturer]. So when my query runs it would filter
the results to match what is entered into the form.

The problem is that I have 10 different search criteria in my form and want
to be able to run the same query without having to fill in every search
criteria.
Right now if I leave one of the criteria blank then my query results will
only pull up entries in which the that field is blank.

How can I make my query criteria only be used if a selection is made in the
form?

I hope that explains what I'm looking for.
Thanks in advance
Travis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top