IIf Statement Problem

G

Guest

I'm trying to use an IIf statement to determine one value or another. However, it keeps coming up the false value when I put in the true value. Here is what the expression looks like:

=IIf([Category]="Carpet","Carpet","Vinyl")

The false option keeps coming up, in this case, it's vinyl. There are two option under the category heading on the form, carpet and vinyl. THis is linked to another table. Am I doing this wrong somehow, or is there something else I'm missing?
 
F

fredg

I'm trying to use an IIf statement to determine one value or another. However, it keeps coming up the false value when I put in the true value. Here is what the expression looks like:

=IIf([Category]="Carpet","Carpet","Vinyl")

The false option keeps coming up, in this case, it's vinyl. There are two option under the category heading on the form, carpet and vinyl. THis is linked to another table. Am I doing this wrong somehow, or is there something else I'm missing?

The IIf statement is OK if the stored value in [Category] is Text
datatype.
I suspect the stored value is a number (from an Option Group or the
bound column of a combo box, or a Look Up field).
If so then:
=IIf([Category]=1,"Carpet","Vinyl")

Change the number value to whatever number represents "Carpet".
 
T

Todd Stephens

Brad said:
I'm trying to use an IIf statement to determine one value or another.
However, it keeps coming up the false value when I put in the true
value. Here is what the expression looks like:

=IIf([Category]="Carpet","Carpet","Vinyl")

The false option keeps coming up, in this case, it's vinyl. There
are two option under the category heading on the form, carpet and
vinyl. THis is linked to another table. Am I doing this wrong
somehow, or is there something else I'm missing?

You might also want to try:
IIf([Category] = "Carpet", [Category], "Vinyl")

T
 
V

Van T. Dinh

Sorry. The IIf posted is not correct.

The 2nd argument needs to be a String which is a Domain name.

--
HTH
Van T. Dinh
MVP (Access)




Todd Stephens said:
Brad said:
I'm trying to use an IIf statement to determine one value or another.
However, it keeps coming up the false value when I put in the true
value. Here is what the expression looks like:

=IIf([Category]="Carpet","Carpet","Vinyl")

The false option keeps coming up, in this case, it's vinyl. There
are two option under the category heading on the form, carpet and
vinyl. THis is linked to another table. Am I doing this wrong
somehow, or is there something else I'm missing?

You might also want to try:
IIf([Category] = "Carpet", [Category], "Vinyl")

T
 
G

Guest

The problem is that in the expression part, it is from a form field which is linked to a different table. There are two choices on the table, Carpet and Vinyl. THis is where my problem is. I have a combo box which drops down with the two choices. I can do it if it isn't linked to the table. I need to find a way to do it so that it is linked to the table.

Van T. Dinh said:
Sorry. The IIf posted is not correct.

The 2nd argument needs to be a String which is a Domain name.

--
HTH
Van T. Dinh
MVP (Access)




Todd Stephens said:
Brad said:
I'm trying to use an IIf statement to determine one value or another.
However, it keeps coming up the false value when I put in the true
value. Here is what the expression looks like:

=IIf([Category]="Carpet","Carpet","Vinyl")

The false option keeps coming up, in this case, it's vinyl. There
are two option under the category heading on the form, carpet and
vinyl. THis is linked to another table. Am I doing this wrong
somehow, or is there something else I'm missing?

You might also want to try:
IIf([Category] = "Carpet", [Category], "Vinyl")

T
 
V

Van T. Dinh

My post addressed Todd's answer which, I thought, was incorrect
syntactically. Maybe, Todd meant a Control [Category] on your Form???

I am not sure about your problem / possible solution reading the description
in your 2 posts.

Perhaps, you should post details of the relevant Tables, the set-up of the
Form, in particular the ComboBox you are referring to, what you want to get
out of the IIf function and where you use the IIf function, e.g. VBA code?
ControlSource of a Control on the Form?

--
HTH
Van T. Dinh
MVP (Access)


Brad said:
The problem is that in the expression part, it is from a form field which
is linked to a different table. There are two choices on the table, Carpet
and Vinyl. THis is where my problem is. I have a combo box which drops
down with the two choices. I can do it if it isn't linked to the table. I
need to find a way to do it so that it is linked to the table.
 

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