A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combining two IIf expressions into one



 
 
Thread Tools Display Modes
  #1  
Old January 21st, 2006, 10:17 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default 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  
Old January 21st, 2006, 10:53 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default 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  
Old January 21st, 2006, 10:55 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default 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  
Old January 22nd, 2006, 03:25 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default 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  
Old January 22nd, 2006, 08:35 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 05:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.