Expression Builder If Statements? (1 Viewer)

Diamond-Leopard

Registered User.
Local time
Today, 04:37
Joined
Oct 30, 2018
Messages
26
Hello, today I am trying to bring accross some of the features of excel but I need a little help...

When I type into a field a certain value I would like another field to automatically change based on the first value.

My image attachment shows what I am trying to achieve.

If One field has a number then I would like another field to say Yes ..

So so so simple but I need a hand lol


So basically I want the field to say "No" Until I put a number in the Top_Cash_Back_Percentage field and then I want the Top_Cash_Back field to say yes.
 

Attachments

  • ddd.gif
    ddd.gif
    42.6 KB · Views: 90

isladogs

MVP / VIP
Local time
Today, 04:37
Joined
Jan 14, 2017
Messages
18,186
Yes/no fields are Boolean with values -1 (true) or 0 (false).
So whilst you can display them as yes/no they aren't text strings.

In your IIF statement replace "yes","no" with e.g. -1,0 or true, false (without quotes)
 

plog

Banishment Pending
Local time
Yesterday, 23:37
Joined
May 11, 2011
Messages
11,613
If One field has a number then I would like another field to say Yes .

Is Top_Cash_Back ever editable by the user? Or is it always dependent on the value in Top_Cash_Back_Percentage?

In other words, is this a valid situation: Top_Cash_Back_Percentage starts off as 5, which triggers Top_Cash_Back to become Yes. Then later on someone changes Top_Cash_Back to No without changing the value in Top_Cash_Back_Percentage?
 

Micron

AWF VIP
Local time
Today, 00:37
Joined
Oct 20, 2018
Messages
3,476
Yes/no fields are Boolean with values -1 (true) or 0 (false).
So whilst you can display them as yes/no they aren't text strings.

In your IIF statement replace "yes","no" with e.g. -1,0 or true, false (without quotes)
Interesting that I was just reviewing this topic last night for another forum. M$ states that True/Yes/On and False/No/Off are logical values and should not be compared to numeric values. When converting Boolean to numeric, False is 0 and True is -1. However, when it's numeric to Boolean, False is again 0 (it is always 0) but True is anything else. As long as quotes are not placed around the Boolean values (e.g. True not "True") those values will work as intended. If I were to make numerical comparisons, I would try to compare to 0, as in

= 0 or <> 0 rather than = -1
That's my 2 cents. Don't spend it all in one place!
 

isladogs

MVP / VIP
Local time
Today, 04:37
Joined
Jan 14, 2017
Messages
18,186
Hi Micron
True is indeed anything else than 0 in terms of interpretation.
However if you enter another non zero value such as 2 in a Boolean field, Access will convert it to -1

Trying to filter a Boolean field for true values in a table or query in datasheet view can sometimes be 'interesting'. I find it doesn't always work

Anyway, I was trying to keep things straightforward :rolleyes:
 
Last edited:

Cronk

Registered User.
Local time
Today, 15:37
Joined
Jul 4, 2013
Messages
2,770
@ Diamond-Leopard
Your table does not need a field, it's superfluous and having it, denormalizes the table because one field is dependent on the contents of another field.


Use a query, form or report to show Yes/no


You are trying to make a table emulate a spreadsheet.
 

Users who are viewing this thread

Top Bottom