Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2005

Tip: Looking for answers? Try searching our database.

Finding Min of Values (dates)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dchristo - 17 Aug 2005 20:45 GMT
I need to find the lowest values of a set of dates, I tried using
MinOfList()
Function MinOfList(ParamArray varValues()) As Variant
   Dim i As Integer        'Loop controller.
   Dim varMin As Variant   'Smallest value found so far.

   varMin = Null           'Initialize to null

   For i = LBound(varValues) To UBound(varValues)
       If IsNumeric(varValues(i)) Then
           If varMin <= varValues(i) Then
               'do nothing
           Else
               varMin = varValues(i)
           End If
       End If
   Next

   MinOfList = varMin
End Function

But nothing happens, can someone please direct me on how to accomplish this?

Thank you
dchristo - 17 Aug 2005 21:17 GMT
I figured it out right after I posted, but thanks

> I need to find the lowest values of a set of dates, I tried using
> MinOfList()
[quoted text clipped - 20 lines]
>
> Thank you
John Nurick - 18 Aug 2005 07:06 GMT
The function is badly named: MinOfListOfNumbers() would be better.

In the present case the problem is caused by IsNumeric() excluding
dates. How about changing it to IsDate() and rename the function to
    MinOfListOfDates

>I need to find the lowest values of a set of dates, I tried using
>MinOfList()
[quoted text clipped - 20 lines]
>
>Thank you

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Douglas J Steele - 18 Aug 2005 12:33 GMT
Initalizing varMin to Null doesn't help either!

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> The function is badly named: MinOfListOfNumbers() would be better.
>
[quoted text clipped - 31 lines]
>
> Please respond in the newgroup and not by email.
John Nurick - 18 Aug 2005 20:46 GMT
>Initalizing varMin to Null doesn't help either!

I don't think that's a problem. If varMin is Null, the
    If varMin <= varValues(i)
will always be False and the assignment
    varMin = varValues(i)
will be made. Am I missing something?

>> >    varMin = Null           'Initialize to null
>> >
[quoted text clipped - 7 lines]
>> >        End If
>> >    Next

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Douglas J. Steele - 19 Aug 2005 12:01 GMT
Sorry, you're right. varMin will get a value assigned the first time, so it
doesn't matter after that.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>>Initalizing varMin to Null doesn't help either!
>
[quoted text clipped - 20 lines]
>
> Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.