Results 1 to 5 of 5
  1. #1
    Join Date
    May 2004
    Posts
    25

    Unanswered: MS Excel function in MS Access

    Hi,

    I need to use MS Excel function "MAX" in MS Access. Is it possible?
    I need to know the max value from 5 numbers and I think I can not use domain function DMAx .
    MS Excel Function Description:

    MAX-Returns the largest value in a set of values.

    Syntax

    MAX(number1,number2,...)

  2. #2
    Join Date
    Jan 2005
    Posts
    6
    Thru a query you can do this:

    SELECT Max([Field_Name]) AS MaxNum FROM Table_Name;

  3. #3
    Join Date
    Feb 2004
    Posts
    137
    hawkeyeboy, this is an excellent suggestion only if you are using the aggregate function MAX withing a grouping query. However, Drahos is looking to emulate the MAX function as structured in Excel. The following should do the trick:

    Create a new Module and save it as modMax.

    Copy and paste the following text into the module:
    Code:
    Public Function MAX(ParamArray Number()) As Double
        Dim x As Double
        For x = 0 To UBound(Number)
            If MAX < Number(x) Then MAX = Number(x)
        Next x
    End Function
    Save the module with these changes.

    To use the function, do exactly as with excel. For example:
    ?MAX(1,7,5,4,19,13)
    ...should return 19.

    See if this works for you, Drahos.

  4. #4
    Join Date
    Jan 2012
    Posts
    1

    Post MS Excel function in MS Access

    it works, but you have to change the name of the function, for example "Max2", because the access recognize the Max function as its own.

  5. #5
    Join Date
    Jan 2012
    Location
    Retford
    Posts
    1

    Thumbs up

    Great thread, it helped me alot. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •