Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

0 to select all records any other value to show matching records

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
I have a form with a combobox where the user can select a department code.
I am trying to show only those records with a matching department code or all of them if the department code selected is 0.
I have tried the following criteria in the query wizard

iif([forms]![selectfrm].[Deptcode] <>0,[forms]![selectfrm].[Deptcode])

I chave been able to show all records by emitting the criteria and show matching records by putting in the criteria.

Any help would be appreciated.

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 



Hi,

When the user selects ZERO, the IIF statement returns FALSE. Is that the value that you want returned to your criteria?

I think not. You will actually have to REMOVE that WHERE statement in your SQL WHERE Clause.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
try
where deptcode=iif([forms]![selectfrm].[Deptcode] =0,deptcode,[forms]![selectfrm].[Deptcode])
 
Criteria:
=[forms]![selectfrm]![Deptcode] OR [forms]![selectfrm]![Deptcode]=0


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top