Results 1 to 3 of 3
  1. #1
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22

    Nexted if and use of max function - help with syntax, please

    Can you help me debug this statement? I'm trying to use the "max" function so that I can decrease the number of if statements. Here's my defined field:



    BetterofRate: IIf([position]=3,0,IIf([position]=1 And [Grid_Assignment]="Locked",[base_rate],IIf([position]=50 And [Grid_Assignment]="Locked",[base_rate],iif(([position]=1,max([br_qual_rate],[rate],[abc_leader_rate]),iif(([position]=50,max([br_qual_rate],[rate],[abc_leader_Rate],0))))

    The error I receive: Expression you entered has a function containing the wrong number of arguments.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    not Max, use DMAX
    Dmax has 3 params: DMax(field, table, where)

    and your where clause makes no sense:
    Dmax( [br_qual_rate], [rate], [abc_leader_rate]????

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Your problem is this : max([br_qual_rate],[rate],[abc_leader_Rate],0)

    Access does not have a function that returns the maximum of an arbitrary number of arguments. Access SQL has a Max function, but it does not work like that, either.

    I think you will need to use Iif functions here.

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

Similar Threads

  1. Right Function SQL syntax help
    By hellfire45 in forum Access
    Replies: 9
    Last Post: 04-07-2015, 11:48 AM
  2. Syntax error 3134 for Add function
    By gaker10 in forum Programming
    Replies: 9
    Last Post: 06-16-2014, 12:06 PM
  3. Function Syntax
    By RayMilhon in forum SQL Server
    Replies: 4
    Last Post: 03-15-2013, 01:40 PM
  4. simple syntax for putting a variable into a function
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 11-02-2012, 09:46 AM
  5. IIF function syntax
    By kris335 in forum Access
    Replies: 5
    Last Post: 09-13-2011, 11:14 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