How to skip a query parameter to view all details.

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

Guest

I have a query with parameters to filter some details, but somtimes I want
to view all details.
 
Use this for your parameter ---
Like [Enter parameter] & "*"
It will use the wildcard when you press the ENTER key without typing
anything at the prompt.
 
Test for each parameter being NULL within parenthesised Boolean OR
expressions, e.g.

SELECT *
FROM Customers
WHERE (State = [Enter State:] OR [Enter State:] IS NULL)
AND (City = [Enter City:] OR [Enter City:] IS NULL);

If no value is entered for a parameter the parenthesised expression will
evaluate to TRUE for every row by virtue of the parameter being NULL, if a
value is entered for the parameter it will only evaluate to TRUE where the
value in the column matches the value entered, so the result will be
restricted to those rows.

Ken Sheridan
Stafford, England
 
Thanks a lot Ken, I have tested this and it worked.
M.A.Halim

Ken Sheridan said:
Test for each parameter being NULL within parenthesised Boolean OR
expressions, e.g.

SELECT *
FROM Customers
WHERE (State = [Enter State:] OR [Enter State:] IS NULL)
AND (City = [Enter City:] OR [Enter City:] IS NULL);

If no value is entered for a parameter the parenthesised expression will
evaluate to TRUE for every row by virtue of the parameter being NULL, if a
value is entered for the parameter it will only evaluate to TRUE where the
value in the column matches the value entered, so the result will be
restricted to those rows.

Ken Sheridan
Stafford, England

M.A.Halim said:
I have a query with parameters to filter some details, but somtimes I want
to view all details.
 

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

Back
Top