How does Access function "maximum" work?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access wouldn't run my query because of "undefined function 'Maximum' in
expression". The field associated with the error message is as follows. Can
someone tell me what's wrong with my field definition? Many thanks!

Field Name: IIf([Field A]<>"0",Val([Field B]),Maximum([Field C],[Field D]))
 
Dear Ramnpr:

There is no such Access function "Maximum." Can you explain where you
got the information there is one?

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Access wouldn't run my query because of "undefined function 'Maximum' in
expression". The field associated with the error message is as follows. Can
someone tell me what's wrong with my field definition? Many thanks!

Field Name: IIf([Field A]<>"0",Val([Field B]),Maximum([Field C],[Field D]))

There is no Maximum operator; there is however a Max operator.

However - it doesn't work this way. It finds the maxiumum value of a
field across records. If you want a function which returns the
greatest of its arguments you'll need to program it yourself. Ok...
let's see... assuming that the field values contain Long Integers:

Public Function Maximum(ParamArray vX() As Variant) As Variant
Dim iPos As Integer
Maximum = -2147483648 ' smallest possible Long
For iPos = 0 to UBound(vX())
If vX(iPos) > Maximum Then Maximum = vX(iPos)
Next iPos
End Function


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Hi Tom,

I expect this is probably that old problem where the help system in some
recent versions of Office used to include Excel functions when you searched
from within Access. Happily, that doesn't seem to happen any more in Access
2003 - at least, not while on-line.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Tom Ellison said:
Dear Ramnpr:

There is no such Access function "Maximum." Can you explain where you
got the information there is one?

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts


Access wouldn't run my query because of "undefined function 'Maximum' in
expression". The field associated with the error message is as follows.
Can
someone tell me what's wrong with my field definition? Many thanks!

Field Name: IIf([Field A]<>"0",Val([Field B]),Maximum([Field C],[Field
D]))
 
Brendan Reynolds said:
I expect this is probably that old problem where the help system in some
recent versions of Office used to include Excel functions when you searched
from within Access.

Good theory, however there is no Excel 'Maximum' function either <g>.

Jamie.

--
 
Drat! I just *know* I remember a 'Maximum' function from *somewhere*. I'm
going to lay awake nights now trying to remember ...

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top