Results 1 to 4 of 4
  1. #1
    andypandy is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    York, United Kingdom
    Posts
    2

    Post Stuck on "Switch" expression.

    Hi there.


    I have an expression within a query which calculates the due date of a project based on the date it was instructed and the time it was instructed.

    Due: Switch([Day]<4 And [Hours]<13, DateAdd("d",2,[Instruction Date])[, [Day]<4 And [Hours]>13, DateAdd("d",3,[Instruction Date])[,[Day] =4 or =5 And [Hours]<13,DateAdd("d",4,[Instruction Date])[,[Day] =4 or =5 And [Hours]>13,DateAdd("d",5,[Instruction Date]) ]]])

    [Day] is a pre-calculated field where it calculates the day of the week in a number from 1 to 7 based on the instruction date.

    [Hours] is a pre-calculated field where it includes only the hour from the time of the instruction.

    [Instruction Date] is the date of instruction... pretty simple.

    ---

    I keep getting an invalid syntax error when trying to run.

    It says, "you may have entered an operand without an operator."

    Any ideas?

    Andy
    Last edited by andypandy; 07-04-2010 at 04:05 PM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try taking out the three sets of []; you only want the ones that surround your field names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    andypandy is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    York, United Kingdom
    Posts
    2
    Wow, thanks. What a silly mistake. I seemed to have misread the access help files. It's running now, thanks for the help pbaldy.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem. My suspicion is that you left in the square brackets that MS typically uses to indicate an optional item.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 13
    Last Post: 12-05-2011, 05:10 AM
  2. Replies: 3
    Last Post: 04-10-2010, 10:22 AM
  3. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  4. Replies: 2
    Last Post: 08-31-2006, 12:19 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

Tags for this Thread

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