Switching True/False Value for Report

Montez659

Well-known Member
Joined
May 4, 2005
Messages
918
The title seems simple enough, and I know what you are thinking, "Just format the textbox as Yes/No or whatever." However, what I am wanting seems a bit more complicated. I am working with a db that was not created by me so I have to work within some bounds.

This is one of them.

The data field is a checkbox that is checked if "No Errors" are present. However, in my report, I want that to display as "Yes/No" with a title of "Errors Present." The way it is structured, if there a box checked (no error) it would display as "Yes" on the report, giving the exact opposite of what it should be.

Soooo...anyway to switch Yes/No to No/Yes for a True/False scenario (i.e., True = No instead of Yes)?

Thanks for the help as always.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You don't say what type of field it is, or what the source for the report is.

There are few methods you could use, for example in a query an expression like this.

YesNo:Iif([FieldName], "No", "Yes")

Though you could dispense with the label in the report and use something like this.

ErrorsReported:Iif([FieldName], "Errors reported", "No errors reported")

I think I might have got the logic mixed up, but I hope you get the idea.

PS You could use these expressions in the report itself if you the source was a table, but using a query as a source can give you a lot more options.
 
Upvote 0
Norie, thanks for the extra info! The field is a textbox and the source is a query. I like your idea of dropping the label and using "Errors Reported" and "No Errors Reported." Great suggestions.
 
Upvote 0
Not sure if it's quicker (probably negligible), rather than using IIF I've started using
Code:
CHOOSE([FieldName]+2,'Yes', 'No')
 
Upvote 0
Darren

How about this?

Format([TheField],""""";""No"";""Yes""")

Don't think I'd rely on it outside Access, or even inside Access for that matter.:)
 
Upvote 0
ok, you've done my head in now at 5pm.

Was looking at it for ages before realising it's just a custom number format.
Can see now why you wouldn't trust it as any negative number is 'Yes' and any positive number is blank.

Least with CHOOSE anything other than -1 and 0 will return an error. :)

Or you could always use:
Code:
YESNO: IIf(NZ([TheField],False)=True,'No',IIf(Not NZ([TheField],False)=True,'Yes',IIf(IsNull(NZ([TheField],False)),Null,Null)))

Double & triple checked for NULL in a boolean field just in case - it is Access after all. :)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top