[AccessD] Max of 20 values

Rocky Smolin rockysmolin at bchacc.com
Sat Jul 23 08:15:34 CDT 2011


Crude as it sounds, twenty IF statements might be the fastest, easiest,
cheapest way.  Easy to read, easy to maintain in the future. 

If the text boxes all have consistent names list txtValuenn where nn is a
number from 01 to 20, then you could do it in a loop, creating the name of
the text box in a string and checking to see if the value in that box is
greater than the currently highest value -- If Me(strtxtBoxName) >
dblCurrentHIgh then dblCurrentHigh = Me(strtxtBoxName).  That would be
clever, harder to maintain 5 years form now, and take....almost 20 lines of
code.

You coud write the twenty values to a temp table and to a Dmax on the table.
That would take about 20 lines of code and would be even longer and more fun
to create.  Or bind the twenty values to a table and put them in a
continuous subform.  Then the Dmax would be easy.  

Or 20 If statements...

R

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Saturday, July 23, 2011 5:54 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Max of 20 values

I have a form into which the user enters up to 20 values (measurements in
time). They all default to zero. I'm trying to think of an elegant way to
find the max value among the 20. Create an array and bubble sort it? I want
to call this code on the AfterUpdate of each of these 20 controls so the
control called MaxReading gets a new value if any of the 20 controls goes
higher than the current MaxReading value.

TIA,
Arthur
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list