Results 1 to 3 of 3
  1. #1
    mike60smart is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    260

    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 Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    4,056
    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 (Mendip Data Systems) : Website, email
    If this has helped, please click the star button and leave a comment

  3. #3
    mike60smart is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    260
    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
  •  
Tech Forums: Microsoft Office Forums