Results 1 to 3 of 3
  1. #1
    shexe is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    71

    IIf Statement Syntax Error

    I continue to receive a syntax error in a nested IIf statement. I am not seeing it but Access keeps highlighting the AS before AprilPercent. Can someone help me de-dug this?




    IIf(([MasterResource-Query].ResourceType="Contractor",IIf(Month([MasterResource-Query].EndDate)<4 And Year([MasterResource-Query].EndDate)=2010,1,NonBillable_2010.April/(22*[MasterResource-Query].AllocationPercent))

    IIf([MasterResource-Query].ResourceType="Intern",IIf(Month([MasterResource-Query].EndDate)<4 And Year([MasterResource-Query].EndDate)=2010,1,NonBillable_2010.April/(20*[MasterResource-Query].AllocationPercent))

    IIf([MasterResource-Query].ResourceType="Employee",IIf(Month([MasterResource-Query].EndDate)<4 And Year([MasterResource-Query].EndDate)=2010,0,NonBillable_2010.April/(20*[MasterResource-Query].AllocationPercent))

    IIf(Month([MasterResource-Query].EndDate)<4,1,NonBillable_2010.April/(22*[MasterResource-Query].AllocationPercent))) AS AprilPercent

    Thanks,
    Sam



  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    shexe,

    a syntax error almost always means that there is a problem parsing the expression out. what that means is that you either left out a character, have too many, or something else that's small. usually it is hard to spot.

    IIf(([MasterResource-Query].ResourceType="Contractor",IIf(Month([MasterResource-Query].EndDate)<4 And Year([MasterResource-Query].EndDate)=2010,1,NonBillable_2010.April/(22*[MasterResource-Query].AllocationPercent))

    IIf([MasterResource-Query].ResourceType="Intern",IIf(Month([MasterResource-Query].EndDate)<4 And Year([MasterResource-Query].EndDate)=2010,1,NonBillable_2010.April/(20*[MasterResource-Query].AllocationPercent))

    IIf([MasterResource-Query].ResourceType="Employee",IIf(Month([MasterResource-Query].EndDate)<4 And Year([MasterResource-Query].EndDate)=2010,0,NonBillable_2010.April/(20*[MasterResource-Query].AllocationPercent))

    IIf(Month([MasterResource-Query].EndDate)<4,1,NonBillable_2010.April/(22*[MasterResource-Query].AllocationPercent))))) AS AprilPercent
    The problem that is immediately visible is your number of outside closing backets. The ones is red that I put in should be added.

    you may have been getting confused with the second IIF() statement in each of those blocks. each block is short one ")" character.

  3. #3
    shexe is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Posts
    71
    You got it - Thanks again!

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

Similar Threads

  1. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  2. Select statement syntax?
    By ksmith in forum Programming
    Replies: 3
    Last Post: 06-24-2010, 09:21 AM
  3. Syntax error
    By smikkelsen in forum Access
    Replies: 6
    Last Post: 04-28-2010, 09:38 AM
  4. sql syntax error
    By SMAlvarez in forum Access
    Replies: 1
    Last Post: 03-12-2009, 09:43 PM
  5. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 PM

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