Query for All

J

Jen

Hi,

I have a table "Project" which fields are ID, Title, Owner, and details, and
due date.
I have a simple form which drop-down box of list of Owner.
Once an owner selected, macro open a query in below and display the result.

SELECT Project.ID, Project.Title, Project.Details, Project.Date
FROM Project
WHERE Project.Owner=Forms!SelectOwner!SelectOwner;

Now my manager asks me to add "All" to the drop-down box and once "All"
selected, display all project.

Could anybody help me?

Thank you in advance.

Jen
 
K

KARL DEWEY

Try this --
WHERE (Project.Owner=Forms!SelectOwner!SelectOwner) Or (Project.Owner Like
IIF(Forms!SelectOwner!SelectOwner = "All", "*", "");
 
D

Douglas J. Steele

Problem with that is that it will not return those rows where Project.Owner
is Null.

Better to use

WHERE ((Project.Owner=Forms!SelectOwner!SelectOwner)
OR (Forms!SelectOwner!SelectOwner = "All"))
 
J

Jen

Thank you for your reply.

Jen

Douglas J. Steele said:
Problem with that is that it will not return those rows where Project.Owner
is Null.

Better to use

WHERE ((Project.Owner=Forms!SelectOwner!SelectOwner)
OR (Forms!SelectOwner!SelectOwner = "All"))
 

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