dmax error

Posted on 2004-11-16
Last Modified: 2008-01-09
Experts, All of the fields following me. are txt fields in my form, based on which the vba runs off of. When I run the code, I get an error message.

dhrsleft = IIf((DMax(Me.hdev, Me.ddev) - > 0, (DMax(Me.hdev, Me.ddev) -, 0)

I am trying to determine the maximum value between hdev & ddev and use that to calculate the variance between that and dev. For example:
if hdev = 10, ddev= 15 and dev= 10 then I want the dhrsleft = max(10,15)-10 = 5

Please help/
Question by:mc7560
    LVL 34

    Accepted Solution

    You cant use dmax to do this, its not the same as Excel's Max function (infact there isnt any Access function that does it.

    Use this

    IIf(Me.hdev > Me.ddev, Me.hdev, Me.ddev) -
    LVL 16

    Assisted Solution

    DMax(Range, Domain) returns the maximum value of the field named Range in table named Domain.
    It does not compare the values of the parameters, it uses them to run a query and return the result.  
    For example: DMax("Cost", "SaleItems").  The query would be:  Select Max(Cost) from SaleItems;
    PS: A third and optional parameter, the Criteria, filters the selection.

    Author Comment

    Oh- that explains the value that I've been getting. Instead of using the if statement, if I wanted to write a public funtion that looked at the value of two fields, how would I create the function?
    LVL 50

    Expert Comment

    by:Steve Bink
    Do not accept this as a solution.

    Public Function MyMax(var1, var2)

    MyMax = IIF(var1 > var2, var1, var2)

    End Function

    In your query/report

    =MyMax(hdev, ddev)

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now