Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a numberic field from Not IsNull 3

Status
Not open for further replies.

Stevehewitt

IS-IT--Management
Jun 7, 2001
2,075
GB
Hi Guys,

Bit of a newbie to this so please bare with me!

I have a text field called "RejectReason". I'm trying create a field on the fly in a query which returns a 1 when there is a entry in the RejectReason field, and a 0 when there is nothing in the field.

This is so I can create totals in a PivotTable.

Any help apprecicated.

Cheers,



Steve.

"They have the internet on computers now!" - Homer Simpson
 
Hi
How about (?):
IIf(Trim([RejectReason]) & "" = "",0,1)
 
Stevehewitt,
In query design view, add this field to your query
EmptyReason:iif(len(trim([RejectReason]))=0;0;1)
 
Hi Guys,

Thank you both. I tried both solutions, but I couldn't get JerryKlmns SQL to work in the query. Thanks for the help.

Remou - Your worked a treat. Thank you very much! :) - A star.

Cheers again guys,



Steve.

"They have the internet on computers now!" - Homer Simpson
 
Sorry guys, just based on the above string, how would I do this if the field it's based on (RejectReason) is a Yes/No field? I've tried to tinker with it but it doesn't want to work! :)

Cheers,



Steve.

"They have the internet on computers now!" - Homer Simpson
 
EmptyReason:iif([RejectReason]=True;0;1)

0=if true
In SQL View the "[blue];[/blue]" changes to "[red],[/red]
 
Simply this:
EmptyReason: Abs([RejectReason])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Cheers JerryKlmns, spot on! Works great - thank you! :)

(I've been playing with the IFF function and reading it on MSDN... sure I'll get there eventually ;-))

Thanks again,




Steve.

"They have the internet on computers now!" - Homer Simpson
 
Shocking! Cheers guys. If I could give more stars I would! :)

Ta,




Steve.

"They have the internet on computers now!" - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top