If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Combining two IIf expressions into one
I am trying to combine two IIf expressions that work fine by themselves into
a single expression. I have fields [Publisher] and [SubPublisher] and two Expressions a) FinalPub: IIf([SubPublisher]="Abracadabra","Abracadabra") b) FinalPub: IIf(IsNull([SubPublisher]),[Publisher]) I want a field (I have called it FinalPub) to either show Abracadabra if the SubPublisher is Abracadabra or the contents of the Publisher field if not. If I run Expression a) my query fills the FinalPub field correctly with Abracadabra if the Sub Publisher is Abracadabra but if there is no sub publisher it returns a blank record. Expression b) returns the Publisher if the SubPublisher filed is blank I don't know if I am getting the syntax wrong or asking an IIf expression to do something it was not designed to do. Help gratefully received. Also if anyone knows of a web or print guide to the basics of building expressions in Access I'd be grateful to know about it. (I find the help in Access 2002 up labyrinthine and unintuitive) peter |
#2
|
|||
|
|||
Combining two IIf expressions into one
IIf statements have 3 parts: the boolean comparison, what to do it it's
true, and what to do if it's false. If you want to return the Publisher information if the SubPublisher isn't Abracadabra, use: FinalPub: IIf([SubPublisher]="Abracadabra","Abracadabra", [Publisher]) If what you want is either Abracadabra or what's in Publisher, and want to handle Nulls and blanks in SubPublisher, try: FinalPub: IIf([SubPublisher] & "" ="Abracadabra","Abracadabra", [Publisher]) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Peter Lawton" wrote in message ... I am trying to combine two IIf expressions that work fine by themselves into a single expression. I have fields [Publisher] and [SubPublisher] and two Expressions a) FinalPub: IIf([SubPublisher]="Abracadabra","Abracadabra") b) FinalPub: IIf(IsNull([SubPublisher]),[Publisher]) I want a field (I have called it FinalPub) to either show Abracadabra if the SubPublisher is Abracadabra or the contents of the Publisher field if not. If I run Expression a) my query fills the FinalPub field correctly with Abracadabra if the Sub Publisher is Abracadabra but if there is no sub publisher it returns a blank record. Expression b) returns the Publisher if the SubPublisher filed is blank I don't know if I am getting the syntax wrong or asking an IIf expression to do something it was not designed to do. Help gratefully received. Also if anyone knows of a web or print guide to the basics of building expressions in Access I'd be grateful to know about it. (I find the help in Access 2002 up labyrinthine and unintuitive) peter |
#3
|
|||
|
|||
Combining two IIf expressions into one
Why not?
IIf([SubPublisher]="Abracadabra" OR [Subpublisher] is Null,[SubPublisher],[Publisher]) Peter Lawton wrote: I am trying to combine two IIf expressions that work fine by themselves into a single expression. I have fields [Publisher] and [SubPublisher] and two Expressions a) FinalPub: IIf([SubPublisher]="Abracadabra","Abracadabra") b) FinalPub: IIf(IsNull([SubPublisher]),[Publisher]) I want a field (I have called it FinalPub) to either show Abracadabra if the SubPublisher is Abracadabra or the contents of the Publisher field if not. If I run Expression a) my query fills the FinalPub field correctly with Abracadabra if the Sub Publisher is Abracadabra but if there is no sub publisher it returns a blank record. Expression b) returns the Publisher if the SubPublisher filed is blank I don't know if I am getting the syntax wrong or asking an IIf expression to do something it was not designed to do. Help gratefully received. Also if anyone knows of a web or print guide to the basics of building expressions in Access I'd be grateful to know about it. (I find the help in Access 2002 up labyrinthine and unintuitive) peter |
#4
|
|||
|
|||
Combining two IIf expressions into one
Whoops! My original response wouldn't work correctly.
IIf([SubPublisher] & "" ="Abracadabra",[SubPublisher],[Publisher]) John Spencer wrote: Why not? IIf([SubPublisher]="Abracadabra" OR [Subpublisher] is Null,[SubPublisher],[Publisher]) Peter Lawton wrote: I am trying to combine two IIf expressions that work fine by themselves into a single expression. I have fields [Publisher] and [SubPublisher] and two Expressions a) FinalPub: IIf([SubPublisher]="Abracadabra","Abracadabra") b) FinalPub: IIf(IsNull([SubPublisher]),[Publisher]) I want a field (I have called it FinalPub) to either show Abracadabra if the SubPublisher is Abracadabra or the contents of the Publisher field if not. If I run Expression a) my query fills the FinalPub field correctly with Abracadabra if the Sub Publisher is Abracadabra but if there is no sub publisher it returns a blank record. Expression b) returns the Publisher if the SubPublisher filed is blank I don't know if I am getting the syntax wrong or asking an IIf expression to do something it was not designed to do. Help gratefully received. Also if anyone knows of a web or print guide to the basics of building expressions in Access I'd be grateful to know about it. (I find the help in Access 2002 up labyrinthine and unintuitive) peter |
#5
|
|||
|
|||
Combining two IIf expressions into one
Thanks. First reply worked a treat.
peter "Peter Lawton" wrote in message ... I am trying to combine two IIf expressions that work fine by themselves into a single expression. I have fields [Publisher] and [SubPublisher] and two Expressions a) FinalPub: IIf([SubPublisher]="Abracadabra","Abracadabra") b) FinalPub: IIf(IsNull([SubPublisher]),[Publisher]) I want a field (I have called it FinalPub) to either show Abracadabra if the SubPublisher is Abracadabra or the contents of the Publisher field if not. If I run Expression a) my query fills the FinalPub field correctly with Abracadabra if the Sub Publisher is Abracadabra but if there is no sub publisher it returns a blank record. Expression b) returns the Publisher if the SubPublisher filed is blank I don't know if I am getting the syntax wrong or asking an IIf expression to do something it was not designed to do. Help gratefully received. Also if anyone knows of a web or print guide to the basics of building expressions in Access I'd be grateful to know about it. (I find the help in Access 2002 up labyrinthine and unintuitive) peter |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Function isn't available in expressions in query expressions - hel | Icmeler | General Discussion | 3 | January 30th, 2008 09:33 PM |
Create Expressions in Access | Jcraig713 | General Discussion | 0 | December 12th, 2005 03:12 PM |
Combining DDE Expressions | Ademar | Mailmerge | 5 | November 12th, 2005 07:23 PM |
Combining expressions | Bill Davis | Running & Setting Up Queries | 3 | September 16th, 2004 12:49 PM |
Function isn't available in expressions in query expression | Derek Ruesch | General Discussion | 1 | July 14th, 2004 11:52 PM |