Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

sql - Query Filter: IIf with return >= case

CIAO!

I need to create a Query filtered in this way:

IIf([Forms]![Discipline_Bah]![F]=">=1",>=1, like [Forms]![Discipline_Bah]![F] )

But the >=1 return always 0.

How can I solve this? thanks for all the answers!

Edit: added more details: I've a form with a ComboBox with the parameters 0; >=1; I wish to filter the data in a query, according to value present in the ComboBox. (the combobox is a string)

iif([combobox]=">=1", then filter >=0; else filter =[combobox])
question from:https://stackoverflow.com/questions/66061179/query-filter-iif-with-return-case

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Operators (>=, =, etc) cannot be dynamic in query object. Have to use a static operator and then IIf() determines what parameter to return.

Consider:

WHERE fieldname LIKE IIf(combobox = "All", "*", combobox)

If your requirements are really more complicated than indicated, advise not to use dynamic query object. Use VBA to conditionally build filter criteria and apply to form or report. Or use VBA to manipulate QueryDefs to modify query object.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...