View Single Post
  #5 (permalink)  
Old 07-02-09, 11:27
sbjnyc sbjnyc is offline
Registered User
 
Join Date: Jul 2009
Posts: 4
Quote:
Originally Posted by drr6670
So i tried the following
=iif([result]>=([forms]![range]![range mid]-10 and [result]<=([forms]![range]![range mid]+10,100,+iif(([result]<([forms]![range]![range mid]-10),(([result]/([forms]![range]![rangemid]-10))*100),+iif([result]<([forms]![range]![range mid]+10),((([forms]![range]![range mid]+10)-([result]-([forms]![range]![range mid]+10))/([forms]![range]![range mid]+10))*100),0))

Which is now giving me "the expression you entered is missing closing parenthesis, bracket (]), or vertical bar(|)" error

if i tack a ) on the end I get " the expression you entered has a function containing the wrong number of arguments."

range mid = 130
range it +- 10 from range mid

result comes from a table of data previously entered

so at this point it is not letting the query run

????????????????????
With long expressions it helps if you break them up first to line up the ()s. Without going too far in I can see that you seem to be putting the ()s in the wrong place.

=iif([result]>=
([forms]![range]![range mid]-10 and [result]<=
([forms]![range]![range mid]+10,100,+iif
( ...
should be

=iif([result]>=[forms]![range]![range mid]-10 and
[result]<=[forms]![range]![range mid]+10,100,
iif(...

It would probably make your code a lot more readable if you created a couple of variables like this.

Set mdRngP10 = [forms]![range]![range mid]+10
Set mdRngM10 = [forms]![range]![range mid]-10

And you get something like this.

=iif([result]>=mdRngM10 and [result]<=mdRngP10,100,
iif([result]<mdRngM10,[result]/mdRngM10*100,
iif([result]<mdRngP10,mdRngP10-([result]-mdRngP10)/mdRngP10*100,0)
)
)

Hope that helps.


Edit: Oh and don't forget to add the dim statement for mdRngP10 and mdRngM10 if you add them as variables.

Last edited by sbjnyc; 07-02-09 at 11:48.
Reply With Quote