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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf statement into query criteria problem 1

Status
Not open for further replies.

haerion

IS-IT--Management
Sep 13, 2006
130
US
Hi guys,

I'm trying to run a query that would take all the data that got > of a txtbox(txtOH) on my form or = of this same txtbox. The > or = are on an option group (chkOH) with value 1 for > and value 2 for =.

If I try it like this:

IIf([forms]![Main Form Info]![chkOH]=1,>[forms]![Main Form Info]![txtOH],[forms]![Main Form Info]![txtOH])

If I select the value 2, it return me the right data, but when I choose value 1, it only give me the data with 0 in it, even if i want > 2.

But if I only write >[forms]![Main Form Info]![txtOH] in the criteria, then it return me all value that got more then the value I entered in the textbox.

If someone could tell me what i'm doing wrong here, thanks!!!
 
Stay away from the query grid and modify the SQL code:
SELECT ...
FROM ...
WHERE (([OH field]>[forms]![Main Form Info]![txtOH] AND [forms]![Main Form Info]![chkOH]=1)
OR ([OH field]=[forms]![Main Form Info]![txtOH] AND [forms]![Main Form Info]![chkOH]=2))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Work like a charm thanks for the insight PHV, here is a well earn star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top