IIf condition

S

skk

Hi!

I'm trying to get the Min value of [SalRate] if the [Setting] = "VT" most of
the record gives the Min value except few. "SalRate" is defined as double and
I'm using Access 2003. Below code is used in form text box, data control
source. Thanks!

=IIf(([Setting]="VT" And [SalRate]>0),Min(IIf([SalRate]>0,[SalRate],Null)))
 
T

twen

=IIf(([Setting]="VT" And
[SalRate]>0),Min(SalRate),IIf([SalRate]>0,[SalRate],Null))

That should work
 
M

Marshall Barton

skk said:
I'm trying to get the Min value of [SalRate] if the [Setting] = "VT" most of
the record gives the Min value except few. "SalRate" is defined as double and
I'm using Access 2003. Below code is used in form text box, data control
source. Thanks!

=IIf(([Setting]="VT" And [SalRate]>0),Min(IIf([SalRate]>0,[SalRate],Null)))


Not sure I understand, but try:

=Min(IIf(Setting]="VT" And SalRate>0, SalRate, Null))
 
S

skk

Thanks a lot Marshall that is the syntax, I wanted to be exact.

=Min(IIf([Setting]="VT" And SalRate>0, [SalRate], Null))

Marshall Barton said:
skk said:
I'm trying to get the Min value of [SalRate] if the [Setting] = "VT" most of
the record gives the Min value except few. "SalRate" is defined as double and
I'm using Access 2003. Below code is used in form text box, data control
source. Thanks!

=IIf(([Setting]="VT" And [SalRate]>0),Min(IIf([SalRate]>0,[SalRate],Null)))


Not sure I understand, but try:

=Min(IIf(Setting]="VT" And SalRate>0, SalRate, Null))
 
M

Marshall Barton

Right. My typing seems to be degrading lately ;-)

Note that the square brackets are not needed unless the name
contains a space or other non-alphnumeric character. I
tried to remove them just to demonstrate that, but I missed
one:

=Min(IIf(Setting="VT" And SalRate>0, SalRate, Null))

Note that Access will put the square brackets in there for
you, so you can save some typing (and the potential typos
caused by it). OTOH, if you put them in, you eliminate the
possibility of Access making a mistake when it tries to
figure out where to add them.
--
Marsh
MVP [MS Access]

Thanks a lot Marshall that is the syntax, I wanted to be exact.

=Min(IIf([Setting]="VT" And SalRate>0, [SalRate], Null))

Marshall Barton said:
skk said:
I'm trying to get the Min value of [SalRate] if the [Setting] = "VT" most of
the record gives the Min value except few. "SalRate" is defined as double and
I'm using Access 2003. Below code is used in form text box, data control
source. Thanks!

=IIf(([Setting]="VT" And [SalRate]>0),Min(IIf([SalRate]>0,[SalRate],Null)))


Not sure I understand, but try:

=Min(IIf(Setting]="VT" And SalRate>0, SalRate, Null))
 
S

skk

Thank you as always for all of us to learn more than what we've asked for.

Marshall Barton said:
Right. My typing seems to be degrading lately ;-)

Note that the square brackets are not needed unless the name
contains a space or other non-alphnumeric character. I
tried to remove them just to demonstrate that, but I missed
one:

=Min(IIf(Setting="VT" And SalRate>0, SalRate, Null))

Note that Access will put the square brackets in there for
you, so you can save some typing (and the potential typos
caused by it). OTOH, if you put them in, you eliminate the
possibility of Access making a mistake when it tries to
figure out where to add them.
--
Marsh
MVP [MS Access]

Thanks a lot Marshall that is the syntax, I wanted to be exact.

=Min(IIf([Setting]="VT" And SalRate>0, [SalRate], Null))

Marshall Barton said:
skk wrote:
I'm trying to get the Min value of [SalRate] if the [Setting] = "VT" most of
the record gives the Min value except few. "SalRate" is defined as double and
I'm using Access 2003. Below code is used in form text box, data control
source. Thanks!

=IIf(([Setting]="VT" And [SalRate]>0),Min(IIf([SalRate]>0,[SalRate],Null)))


Not sure I understand, but try:

=Min(IIf(Setting]="VT" And SalRate>0, SalRate, Null))
 
Top