IIF and Checkboxes

E

Ella

I’m trying to run an up date query, if the checkbox is True then un-check it.
If the checkbox is false then check it.

UPDATE tbDetails SET tbDetails.Priority =
IIf("Priority"=False,IIf("Priority"=True,False),True)
WHERE (((tbDetails.SADID)=[Forms]![frmReview]![frmReviewSub]![SADID]));

Is this possible?

Any advice appreciated
Ella
 
A

Allen Browne

So you want to flip it?

UPDATE tbDetails
SET tbDetails.Priority = NOT tblDetails.Priority
WHERE ...
 
J

John Spencer

By the way, your code failed because you were testing a string to see if it
was True or False.

"Priority" = False should be
[Priority] = False

If I were using the IIF expression, I would write the query as follows.

UPDATE tbDetails
SET tbDetails.Priority = IIf([Priority]=False,True,False)
WHERE (((tbDetails.SADID)=[Forms]![frmReview]![frmReviewSub]![SADID]));

I would go with Allen Browne's version.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
E

Ella

Thank you both!
I tried both answers and both worked well.
So I took John's advice and used Allen's suggestion.

Ella
 

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