Max of one of several Report fields

T

Tom Green

I have a report with 4 columns. I'd like to enter a fifth column that simply
displays the max of one of the four at left. Silly, but this is what the
client wants. Max returns the Max of a single field, MAXA doesn't apply. I
suspect my syntax is not parsing:

=MAX(([Field1],[Field2],[Field3],[Field4]))

Domain aggregate functions also seem to apply only to a single field in the
dataset as opposed to disambiguating which is greatest. Any ideas?

Thanks in advance
 
M

Marshall Barton

Tom said:
I have a report with 4 columns. I'd like to enter a fifth column that simply
displays the max of one of the four at left. Silly, but this is what the
client wants. Max returns the Max of a single field, MAXA doesn't apply. I
suspect my syntax is not parsing:

=MAX(([Field1],[Field2],[Field3],[Field4]))

Domain aggregate functions also seem to apply only to a single field in the
dataset as opposed to disambiguating which is greatest.

There is no built in function to find the max of a list of
values. Here's a little function I use for this kind of
thing:

Public Function MaxOfList(ParamArray vValues() As Variant)
As Variant
Dim vX As Variant

MaxOfList = vValues(0)
For Each vX In vValues
If vX > MaxOfList Then MaxOfList = vX
Next vX

End Function
 
T

Tom Green

Very creative. From what I understand it's not possible to assign the
ControlSource property to a report control at runtime from code (is there a
way?), so how can I implement this?

Thanks!

Marshall Barton said:
Tom said:
I have a report with 4 columns. I'd like to enter a fifth column that simply
displays the max of one of the four at left. Silly, but this is what the
client wants. Max returns the Max of a single field, MAXA doesn't apply. I
suspect my syntax is not parsing:

=MAX(([Field1],[Field2],[Field3],[Field4]))

Domain aggregate functions also seem to apply only to a single field in the
dataset as opposed to disambiguating which is greatest.

There is no built in function to find the max of a list of
values. Here's a little function I use for this kind of
thing:

Public Function MaxOfList(ParamArray vValues() As Variant)
As Variant
Dim vX As Variant

MaxOfList = vValues(0)
For Each vX In vValues
If vX > MaxOfList Then MaxOfList = vX
Next vX

End Function
 
M

Marshall Barton

Tom said:
Very creative. From what I understand it's not possible to assign the
ControlSource property to a report control at runtime from code (is there a
way?), so how can I implement this?


I don't see where runtime has anything to do with your
question. Just set the text box's Control Source in design
view:
=MaxOfList([Field1],[Field2],[Field3],[Field4])
--
Marsh
MVP [MS Access]


Tom said:
I have a report with 4 columns. I'd like to enter a fifth column that simply
displays the max of one of the four at left. Silly, but this is what the
client wants. Max returns the Max of a single field, MAXA doesn't apply. I
suspect my syntax is not parsing:

=MAX(([Field1],[Field2],[Field3],[Field4]))

Domain aggregate functions also seem to apply only to a single field in the
dataset as opposed to disambiguating which is greatest.
Marshall Barton said:
There is no built in function to find the max of a list of
values. Here's a little function I use for this kind of
thing:

Public Function MaxOfList(ParamArray vValues() As Variant)
As Variant
Dim vX As Variant

MaxOfList = vValues(0)
For Each vX In vValues
If vX > MaxOfList Then MaxOfList = vX
Next vX

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top