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!

How To Retrieve All Records Within IIF Statement (Without Wildcard??)

Status
Not open for further replies.

dominicdunmow

Technical User
Jul 28, 2004
125
CA

I have a table with a filed named "LC". All records have 1 of 4 values for "LC": - for example "Bob", "bill", "ben" or "baz".

I query this table using a value returned from a combo box in a form. The values in the combo box are "Bob", "bill", "ben" or "baz".

To query all records with Baz in LC field, I select Baz from the dropdown and click the command buttin and the query returns the appropriate dataset.

But I can't figure out how what to input in the QBE criteria to return all records.

Currently I use this line to return individual recordsets:-

IIf(([forms]![Services_Opportunity_Pipeline_Report_Menu]![LC Report]="Baz" Or ([Main Report].[Lead_LC]) Like "Bill" Or ([Main Report].[Lead_LC]) Like "Ben" Or ([Main Report].[Lead_LC]) Like "Bob"),[forms]![Services_Opportunity_Pipeline_Report_Menu]![LC Report],"")

Logic would tell me to add a wildcard to the negative side of the IIF statement but this doesn't work. Can anybody help please?

 
I think I may have found the answer:-

Why you cannot use a * in an IIf function
The IIf function assumes that the wildcard * is a literal character and will return a * when the expression is true. To return the complete contents of a field you need to enter the field name as the argument in the expression. The following code can be entered in the Field row entry. It will display an invoice date when it is before today's date and nothing otherwise:

Date: IIf([Invoice Date]<Date(),[Invoice Date])

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top