Expression in query

G

Guest

In a query I have the following expression:

IIf([Tasks]![TaskID]='59' &
[Tasks]![OccursInFactory]='Yes',(([Tasks]![TimeSeconds]=[Jobs Per
Day]*0.1)*60))

This does not work as the query says it is too complicated. I would be glad
to run this in code behind a form (which is why I am trying to make a query
work with the expression) as there is only on record (59) I need a custom
math expression and only if the field [Tasks]![OccursInFactory]='Yes'.

The way I want the expression to work is in a form that has a query where
record 59 is on of the returned records. Somewhere in this form, possibly in
the after update of it's check box [Tasks]![OccursInFactory] = Yes, I want to
change the value in Table field ,[Tasks]![TimeSeconds] to equal a value
entered by the user and have that value =[Value Entered By User]*0.1)*60.
This value should then be written to [Tasks]![TimeSeconds].

How can I do that?

Thanks,

Dennis
 
J

John Vinson

In a query I have the following expression:

IIf([Tasks]![TaskID]='59' &
[Tasks]![OccursInFactory]='Yes',(([Tasks]![TimeSeconds]=[Jobs Per
Day]*0.1)*60))

This does not work as the query says it is too complicated.

The & character is an string operator which concatenates strings.
You're using it in place of the AND term in SQL syntax.

Try replacing the ampersand with the literal word AND.

John W. Vinson[MVP]
 
G

Guest

John,

That corrected the syntax but I still get the error that says "The
expression is typed incorrectly or is too complicated to be evaluated. For
example a numeric expression may contain too many complicated elements. Try
simplfying the expression by assigning parts of the expression to variables".
--
Thanks,

Dennis


John Vinson said:
In a query I have the following expression:

IIf([Tasks]![TaskID]='59' &
[Tasks]![OccursInFactory]='Yes',(([Tasks]![TimeSeconds]=[Jobs Per
Day]*0.1)*60))

This does not work as the query says it is too complicated.

The & character is an string operator which concatenates strings.
You're using it in place of the AND term in SQL syntax.

Try replacing the ampersand with the literal word AND.

John W. Vinson[MVP]
 
V

Van T. Dinh

* Is TaskID a Numeric Field or a Text Field? Your expression uses it as a
Text Field?

* Is OccursInFactory a Boolean Field or a Text Field? You expression
indiciates a Text Field also?

* Your IIf construct has only 2 arguments AFAICS. Normally, IIf() has 3
arguments. Check Access Help for further info.
 

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