Results 1 to 7 of 7
  1. #1
    harryklein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    48

    Function to return the highest value

    Hi,

    I would like to ask, if you are aware of a function that returns the max-value of a given number-range.
    Like the MAX in excel, not the one can be used in sql-query.
    Like this:

    Max(1,2,3) returns 3.



    Thank you

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Can you give a fuller explanation of what you are trying to do.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    harryklein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    48
    I need to insert records into a table, and there is a field where I need to put the highest value out of four other fields.
    If there would be a function like MaxList, then I would do something like this:
    Code:
     
    INSERT INTO MyTable Field1 Values(MaxList(Field1, Field2, Field3))
    Meaning that Field1 should get the highest value from the list.
    I know, nested IIF-s could be also used, but in case there are more fields in the query, it is a bit confusing to build the expression.

    Thank you

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Did you see the link in post 3?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    harryklein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    48
    I have just red it, yes, this is exactly what I need.
    Thank you.
    I am not sure (of course can try easily):
    if I put these functions into a module, then I can use them in a query ?

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Yes, if you put them in a standard module, not behind a form/report.
    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: 2
    Last Post: 08-15-2019, 11:28 AM
  2. Replies: 15
    Last Post: 12-22-2016, 12:16 PM
  3. Replies: 5
    Last Post: 06-24-2013, 04:25 PM
  4. Replies: 1
    Last Post: 02-13-2012, 04:58 PM
  5. Query to return only the row containing the highest date.
    By eric.opperman1@gmail.com in forum Queries
    Replies: 4
    Last Post: 03-22-2011, 08:42 PM

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