Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6122089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:30+00:00 2026-05-23T15:51:30+00:00

VBA for Access lacks a simple Max(x,y) function to find the mathematical maximum of

  • 0

VBA for Access lacks a simple Max(x,y) function to find the mathematical maximum of two or more values. I’m accustomed to having such a function already in the base API coming from other languages such as perl/php/ruby/python etc.

I know it can be done: IIf(x > y, x,y). Are there any other solutions available?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:51:31+00:00Added an answer on May 23, 2026 at 3:51 pm

    I’ll interpret the question to read:

    How does one implement a function in Access that returns the Max/Min of an array of numbers? Here’s the code I use (named “iMax” by analogy with IIf, i.e., “Immediate If”/”Immediate Max”):

      Public Function iMax(ParamArray p()) As Variant
      ' Idea from Trevor Best in Usenet MessageID rib5dv45ko62adf2v0d1cot4kiu5t8mbdp@4ax.com
        Dim i As Long
        Dim v As Variant
    
        v = p(LBound(p))
        For i = LBound(p) + 1 To UBound(p)
          If v < p(i) Then
             v = p(i)
          End If
        Next
        iMax = v
      End Function
    
      Public Function iMin(ParamArray p()) As Variant
      ' Idea from Trevor Best in Usenet MessageID rib5dv45ko62adf2v0d1cot4kiu5t8mbdp@4ax.com
        Dim i As Long
        Dim v As Variant
    
        v = p(LBound(p))
        For i = LBound(p) + 1 To UBound(p)
          If v > p(i) Then
             v = p(i)
          End If
        Next
        iMin = v
      End Function
    

    As to why Access wouldn’t implement it, it’s not a very common thing to need, seems to me. It’s not very “databasy”, either. You’ve already got all the functions you need for finding Max/Min across domain and in sets of rows. It’s also not very hard to implement, or to just code as a one-time comparison when you need it.

    Maybe the above will help somebody.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am planning to insert value in a vba access form text box values
So i'm new to working with vba in access and i'm having trouble getting
In Access VBA, I want to use values from a Settings table, instead of
Whats the best way to round in VBA Access? My current method utilizes the
This request is based in MS Access VBA. I would like to know what
I coded something using Date statement in Access VBA. It was working fine until
I am trying to create a recordset in Access VBA that will show me
Is there an equivalent to Thread.Sleep() in Access VBA?
I am trying to use batch updates in Access VBA. My code works fine
Can anyone give me details of runtime error 3734 in Access vba. For reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.