Results 1 to 3 of 3
  1. #1
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557

    IIf Error

    Hi Everyone



    What is wrong with this IIf statement?

    I get Invalid Syntax error.

    Code:
    Cal: IIf([P]="New”,DateAdd("yyyy",1,[PurchaseDate],IIf([P]="1”,DateAdd("yyyy",1,[InspectionDate],IIf([P]=”2”,DateAdd("yyyy",2,[InspectionDate])))

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by mike60smart View Post
    Hi Everyone
    What is wrong with this IIf statement?
    I get Invalid Syntax error.
    Bracketing and quote errors. Try this

    Code:
    Cal: IIf([P]="New",DateAdd("yyyy",1,[PurchaseDate]),IIf([P]="1",DateAdd("yyyy",1,[InspectionDate]),IIf([P]="2",DateAdd("yyyy",2,[InspectionDate]))))
    or remove the final IIf and just use this

    Code:
    Cal: IIf([P]="New",DateAdd("yyyy",1,[PurchaseDate]),IIf([P]="1",DateAdd("yyyy",1,[InspectionDate]),DateAdd("yyyy",2,[InspectionDate])))
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi Colin

    That works

    Many thanks

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

Similar Threads

  1. Replies: 5
    Last Post: 07-15-2019, 10:20 AM
  2. Replies: 1
    Last Post: 09-22-2016, 05:05 AM
  3. Replies: 1
    Last Post: 07-26-2016, 06:34 AM
  4. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  5. Replies: 0
    Last Post: 07-16-2012, 05:42 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