Learn how to a build a cloud-first strategyRegister Now


Problem with IIf

Posted on 2011-10-21
Medium Priority
Last Modified: 2013-11-05
I am having a problem with an IIf in a text box control source.  What is wrong with this code?

=IIf([txtTotal PartNQtyNeeded]-[txtTotAvail])=<0, 0, [txtTotal PartNQtyNeeded]-[txtTotAvail])

Question by:SteveL13
  • 2
  • 2
  • 2
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 500 total points
ID: 37008626
the "=" sign must be after the "<"

=IIf([txtTotal PartNQtyNeeded]-[txtTotAvail])<= 0, 0, [txtTotal PartNQtyNeeded]-[txtTotAvail])

Author Comment

ID: 37008696
Got that.  But I also get an error...  "The espression you entered has a function containing the wrong number of arguments".

LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37008762
check again what you have ...
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.


Author Comment

ID: 37008777
Here is exactly what I have... (copy and paste)

LVL 61

Assisted Solution

mbizup earned 500 total points
ID: 37008803
In addition to what cap noticed, your parentheses were mismatched.

You can do either this:
= IIf(([txtTotal PartNQtyNeeded]-[txtTotAvail]) <= 0, 0, [txtTotal PartNQtyNeeded]-[txtTotAvail])

Or this:

=IIf([txtTotal PartNQtyNeeded]-[txtTotAvail] <= 0, 0, [txtTotal PartNQtyNeeded]-[txtTotAvail])

LVL 61

Expert Comment

ID: 37008839
Just a tip...

For syntactical issues in control sources like this, you can put the expression in the VBA editor like this:

x = IIf([txtTotal PartNQtyNeeded]-[txtTotAvail] <= 0, 0, [txtTotal PartNQtyNeeded]-[txtTotAvail])

Doing so makes it easier to track down errors (the expressions turn red if the syntax is off).

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question