IIf or if statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

The first and the second columns are check boxes on the datasheet view. I
would like to create another column [Expr1], (with if statement) based on the
value of the checkboxes in the first two columns, something like IF
package_accepted_ok = checked then column3 ="accepted" or if
[Package_status_rejected]=checked then column3 =rejected.

Do you have an idea how to write in the query?

Thanks in advance,
 
In the design view of the query, go to the first empty column. Type this
expression for the Field:

Translation: IIf([package_accepted_ok]=True,"accepted",
IIf([Package_status_rejected]=True,"rejected","no status"))
 
Hi, Ben.

If the two columns are mutually exclusive and they are in the same table,
then your table doesn't need two separate columns, just one.

One column can store the value, and the query can display an alias (i.e.,
"Expr1:" or you can name it something like "Status:" if you don't like the
default) based upon whichever value (True/False) is in this single column.
For example, if this column were named "PkgStatus," then:

Status: IIf([PkgStatus], "Accepted", "Rejected")

or if you are using SQL:

SELECT IIf([PkgStatus], "Accepted", "Rejected") AS Status
FROM MyTable;

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 
Back
Top