Criteria in a query field?

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

Guest

Hi!
I have a question about making criteria in a field. The field is
employeeID. Now it will show all employeeID. Now I want to change to this:
If user select an employee ID, the query only show the matched employeeID.
If user didn't select an employee ID, the query will show all employeeID.


I tried IIf, but it didn't work as I though. Any idea? Thank you.
 
Try this

Select * From EmployeeTable Where [employee ID] Like Nz([Please Select
employee:],"*")
 
I am not sure how to use your statement.
I think I need add more details...........:>
EmployeeID is one field(culomn) inside the query. SelectEmployeeID is from a
Form.


IF [Forms]![SelectEmployee]![EmployeeID] = "*"
Show all employee
else
show only matched employee

Can I put this logic in Criteria section of the employeeID?
Thank you.

Ofer said:
Try this
Select * From EmployeeTable Where [employee ID] Like Nz([Please Select
employee:],"*")
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



fox said:
Hi!
I have a question about making criteria in a field. The field is
employeeID. Now it will show all employeeID. Now I want to change to this:
If user select an employee ID, the query only show the matched employeeID.
If user didn't select an employee ID, the query will show all employeeID.


I tried IIf, but it didn't work as I though. Any idea? Thank you.
 
Then use this

Select * From TableName Where FieldName Like
[Forms]![SelectEmployee]![EmployeeID]
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



fox said:
I am not sure how to use your statement.
I think I need add more details...........:>
EmployeeID is one field(culomn) inside the query. SelectEmployeeID is from a
Form.


IF [Forms]![SelectEmployee]![EmployeeID] = "*"
Show all employee
else
show only matched employee

Can I put this logic in Criteria section of the employeeID?
Thank you.

Ofer said:
Try this
Select * From EmployeeTable Where [employee ID] Like Nz([Please Select
employee:],"*")
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



fox said:
Hi!
I have a question about making criteria in a field. The field is
employeeID. Now it will show all employeeID. Now I want to change to this:
If user select an employee ID, the query only show the matched employeeID.
If user didn't select an employee ID, the query will show all employeeID.


I tried IIf, but it didn't work as I though. Any idea? Thank you.
 
I tried to put in my query's criteria section, but it won't take it. It said

The Syntax of the subquery in this expression is incorrect.
Check the subquery's syntax and enclose the subquery in parentheses.
 
can you post the SQL you are using?
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



fox said:
I tried to put in my query's criteria section, but it won't take it. It said

The Syntax of the subquery in this expression is incorrect.
Check the subquery's syntax and enclose the subquery in parentheses.

Ofer said:
Then use this

Select * From TableName Where FieldName Like
[Forms]![SelectEmployee]![EmployeeID]
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
Hi!
I have a question about making criteria in a field. The field is
employeeID. Now it will show all employeeID. Now I want to change to this:
If user select an employee ID, the query only show the matched employeeID.
If user didn't select an employee ID, the query will show all employeeID.


I tried IIf, but it didn't work as I though. Any idea? Thank you.

Try a criterion of

[Enter Employee ID:] OR [Enter Employee ID:] IS NULL

John W. Vinson[MVP]
 
Back
Top