IIF Statement - Problem

G

Greg

Hi All,

Getting close to deadline and i know this is has to be simple, what am i
doing wrong?

=IIf([tblStaff.type]="Commission",0) Or IIf([tblStaff.type]="Wages",[Wages],0)

This string is typed in the Control Source of field [Wages].

I simply want the field [Wages] to display $0.00 if
[tblStaff.type]="Commission" otherwise display it's current value.

Thanks in advance for any input.

Greg.
 
W

Wayne Morgan

Try:

=IIf([tblStaff].[Type]="Commission", 0, [Wages])

This will display 0 if [Type] is "Commission" and will display [Wages] if
[Type] is anything other than "Commission". If there are other types that
you want to show different values for, let me know.
 
G

Greg

Hi Wayne,

I get #Error.

I understand your explanation and it make sense.

Do you think the string should include IIf([tblStaff.type]="Wages",[Wages]?

Greg.



Wayne Morgan said:
Try:

=IIf([tblStaff].[Type]="Commission", 0, [Wages])

This will display 0 if [Type] is "Commission" and will display [Wages] if
[Type] is anything other than "Commission". If there are other types that
you want to show different values for, let me know.

--
Wayne Morgan
MS Access MVP


Greg said:
Hi All,

Getting close to deadline and i know this is has to be simple, what am i
doing wrong?

=IIf([tblStaff.type]="Commission",0) Or
IIf([tblStaff.type]="Wages",[Wages],0)

This string is typed in the Control Source of field [Wages].

I simply want the field [Wages] to display $0.00 if
[tblStaff.type]="Commission" otherwise display it's current value.

Thanks in advance for any input.

Greg.
 
G

Greg

Wayne,

Some extra info.

The part of the string making the field display $0.00 if tblStaff.Type =
Commission works perfectly.

I get the #Error when the tblStaff.type = Wages.

Greg.



Wayne Morgan said:
Try:

=IIf([tblStaff].[Type]="Commission", 0, [Wages])

This will display 0 if [Type] is "Commission" and will display [Wages] if
[Type] is anything other than "Commission". If there are other types that
you want to show different values for, let me know.

--
Wayne Morgan
MS Access MVP


Greg said:
Hi All,

Getting close to deadline and i know this is has to be simple, what am i
doing wrong?

=IIf([tblStaff.type]="Commission",0) Or
IIf([tblStaff.type]="Wages",[Wages],0)

This string is typed in the Control Source of field [Wages].

I simply want the field [Wages] to display $0.00 if
[tblStaff.type]="Commission" otherwise display it's current value.

Thanks in advance for any input.

Greg.
 
W

Wayne Morgan

Since you're specifying the table name for Type, I assume it is necessary.
Is there more than one Wages? If so, you may need to specify the table there
also. Do you have a control (i.e. textbox) also called Wages? If so, change
the control name to txtWages to disambiguate the name.
 
E

Eric Johnson

Greg,

Assuming [tblStaff.type] has either "Commission" or "Wages", does the
following meet your need? I think the OR & additional stuff in your IIF is
unnecessary. In the code below, the IIF returns zero if [tblStaff.type]
contains the value "Commission", and the value in field [Wages] if
[tblStaff.type] does not contain the value "Commission".

IIf([tblStaff.type]="Commission",0,[Wages])

-- Eric Johnson
 
M

Mark Burns

Greg,

=IIf([tblStaff].[type]="Commission",0,
IIf([tblStaff].[type]="Wages",[Wages],0))

(note: [tblStaff].[type] NOT [tblStaff.type])...
The problem might also be as Wayne said that [type] and/or [Wages] is not
sufficieintly unambiguous in your database schema/form control names.
 

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

Similar Threads

IIF Statement 1
IIF Statement - Further Issue 3
Calculating Numbers 0
If then else Sql statements HELP 1
Total Query 3
IIF Statement Help 7
Not good with IIF statements 1
IIf statement sometimes works 3

Top