Changing criteria on the fly

G

Guest

I have a form that has a check box and a button that runs a query

Inf the field line of the query I have the field

Auctio

In the criteria section I have

IIf([Forms]![frmReports].[chkAuctionAll]=-1,Like "*",GetAuction()

When the box IS NOT CHECKED the query runs fine and brings in the criteria from GetAuction(). However when the box is checked no records are brought in when it should be bringing all records in.

One more caveat. When I save and close the query and then go back into it Access has changed the criteria line to

IIf([Forms]![frmReports].[chkAuctionAll]=-1,([tblSmartSourcingCostSavings].[Auction]) Like "*",GetAuction()

Any help would be appreciated. Additional things if have tried are

IIf([Forms]![frmReports].[chkAuctionAll]=-1,"",GetAuction()
IIf([Forms]![frmReports].[chkAuctionAll]=-1,,GetAuction()
IIf([Forms]![frmReports].[chkAuctionAll]=-1,Not is Null,GetAuction()
 
J

John Spencer (MVP)

Try the following. You can change the parameter of the criteria using an IIF
statement, but you cannot change the comparision operator. Your method was
attempting to change between equals and Like.

Like IIf([Forms]![frmReports].[chkAuctionAll]=-1,"*",GetAuction())
 

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