Results 1 to 2 of 2
  1. #1
    Troy12 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    1

    Red face Simple IIf statement I cant seem to get working!

    Hi all,



    I am a begginer to MS access and i am struggling with my first IIF statement.
    What i need to do is compare month by month sales for 2010 and 2011 and insert text to say if the sales are increasing or decreasing for that particular month. I have managed to do that fine for the first 6 months using the below statement.

    My IIF Statement
    a: IIf([Diff]>0,"decrease","Increase")

    My IIF statement is based on the difference column i inserted (see below)
    Diff: [Complete payments_Crosstab]![2010]-[Complete payments_Crosstab]![2011]

    However, because i do not yet have the sales figures for the last 6 months in 2011 access is reading the value as 0 and showing these values as 'decrease' when really i would like to just leave these cells blank up until the point the information is available.
    I think i need a isnull statement within the above iif statement but i am not quite sure.

    I would be grateful for some advice as i have spent all morning trying to work this one out. Thanks!
    Last edited by Troy12; 07-30-2011 at 04:28 AM. Reason: missed info

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    IIf([Diff]>0,"decrease",iif([Diff] <0,"Increase", iif([Diff] = 0, "No Change", null)))

    Try something like this, with nested IIF statements

    Basically you are allowing for only two options if the difference is greater than 0 and anything else when really you have 5 options

    1. Diff > 0
    2. Diff <0
    3. Diff = 0
    4. Diff is a null value (I don't know what your data looks like but this may be a possibility)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Delete SQL statement not working properly
    By Alexandre Cote in forum Programming
    Replies: 3
    Last Post: 10-18-2010, 12:56 PM
  2. Textbox IIF statement not working
    By jgelpi16 in forum Forms
    Replies: 2
    Last Post: 08-22-2010, 08:41 PM
  3. is this a valid SQL statement ? (simple)
    By markjkubicki in forum Queries
    Replies: 1
    Last Post: 07-22-2010, 06:49 PM
  4. Replies: 2
    Last Post: 08-26-2009, 10:43 AM
  5. Simple Nav Form Code Not Working
    By alsoto in forum Forms
    Replies: 10
    Last Post: 04-10-2009, 09:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums