Link to home
Start Free TrialLog in
Avatar of mc7560
mc7560Flag for United States of America

asked on

dmax error

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) - Me.dev) > 0, (DMax(Me.hdev, Me.ddev) - Me.dev), 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/
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mc7560

ASKER

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?
Avatar of 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)