Results 1 to 8 of 8
  1. #1
    PATRICKPBME is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    171

    Syntax error (comma) in query expression

    "Syntax error (comma) in query expression"

    I get the noted error message and can't figure out why. Here is what I wrote:

    1st FMV Review: (IIF([FMV Expires]>[End Date],[FMV Expires]-90,[End Date]-90)) This part worked fine, the I attempted to nest as follows:

    1st FMV Review: (IIf([FMV Expires]>[End Date],[FMV Expires]-90,[End Date]-90),IFF([FMV Effective]="1-1-1","NA","NA")))



    Adding that new stuff causes the error message. Can anyone show me what I am missing?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    IFF is not a function.

    and IIF has IIF( statment, TRUE part, false part)

  3. #3
    PATRICKPBME is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    171
    Okay, thanks. I corrected the IFF to IIF and ended up with the following:


    1st FMV Review: (IIf([FMV Expires]>[End Date],[FMV Expires]-90,[End Date]-90), and IIF([FMV Effective]="1-1-1","NA","NA")))

    and now the error message says:

    "The expression you entered contains an invalid syntax. You may have entered an operand without an operator."

    Still at a loss as to what it is telling me I have to do...

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    It is possible to have nested IIF statements but not written like that
    However, the second iif is pointless as the answer if always NA.

    Perhaps you should explain what your possible outputs could be
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    PATRICKPBME is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    171
    I will try... I am trying to get the query to give me either 1 of 2 dates or a response that says NA.

    There are basically 3 fields I want the query to look at with and insert 1 of the answers.

    Two get 1 of 2 date, I tell it if FMV Expires > End Date" the "true" result is the FMV Expires - 90, the "false" result is End Date - 90. With just that it works fine.

    THEN I want the query to look at another field (FMV Effective)and if it finds "1-1-1" to enter NA because there is no FMV date applying to the records with that date as an effective date. The last part is what is making Access flash the error message.

  6. #6
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    OK - so we do the 2nd criterion (part in RED) first as that is the over-riding condition
    If that's false, we run the other IIf

    Code:
    1st FMV Review:  IIF([FMV Effective]="1-1-1","NA",IIf([FMV Expires]>[End Date],[FMV Expires]-90,[End Date]-90))
    Hope that makes sense and does what you want
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  7. #7
    PATRICKPBME is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    171
    Makes perfect sense and gets me out of the error message. Unfortunately, when I run the query I get #Error in the spreadsheet/report where I wanted NA. I thought this was maybe because the field was a date/time field. Changed it to text but it still would not insert the NA I need. Still, you have helped me make progress and I thank you for that! I 'll try to figure out what the formatting problem is.

  8. #8
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Without seeing your data i can't advise further. However this sounds odd:
    if it finds "1-1-1" to enter NA because there is no FMV date applying to the records with that date as an effective date
    Is that 1st January in the Year 1? If so, that is a problem as Access can't handle dates before the year 100.
    The reason for that is confusion between e.g. 99 and 1999 (when in 2 digit format)
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Replies: 2
    Last Post: 10-09-2014, 10:53 AM
  2. Syntax error (comma) in query expression
    By Access_Novice in forum Queries
    Replies: 4
    Last Post: 09-10-2014, 04:14 PM
  3. Replies: 1
    Last Post: 11-30-2011, 01:13 AM
  4. Syntax error (comma) in query expression?
    By TheWolfster in forum Queries
    Replies: 5
    Last Post: 05-10-2010, 12:02 PM
  5. Syntax error (comma) in query expression
    By KLynch0803 in forum Programming
    Replies: 3
    Last Post: 01-18-2010, 03:35 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