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 / Queries / April 2006

Tip: Looking for answers? Try searching our database.

DMax or something else?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George - 28 Apr 2006 09:25 GMT
Hello everybody - Need help again.

I have a non-normalised (as I believe) database, having three fields (a, b
and c), in which my colleaques record numbers.  How can I find the maximum
number recorded in those fields for each record?

Thanking you in advance
Michel Walsh - 28 Apr 2006 11:30 GMT
Hi,

iif( a> b,  iif( a>c, a, c), iif(b>c, b, c))

Hoping it may help,
Vanderghast, Access MVP

> Hello everybody - Need help again.
>
[quoted text clipped - 3 lines]
>
> Thanking you in advance
Dale Fye - 28 Apr 2006 13:41 GMT
George,

Another option is to create a function to do the comparison for you.  I
wrote this a number of years ago when I was working with dates a lot, and
needed to know the larger of two dates.  I later expanded it to take as many
arguments as I wanted, when one of my clients had the same problem you have,
but more columns.  You can pass this function any number of arguments (fields
in your case) and it will return the largest value.

Public Function MaxVal(ParamArray MyArray()) As Variant

   Dim varMax As Variant
   Dim intLoop As Integer
   varMax = Null
   
   For intLoop = LBound(MyArray) To UBound(MyArray)
       If IsNull(MyArray(intLoop)) Then
           'do nothing
       ElseIf IsNull(varMax) Or MyArray(intLoop) > varMax Then
           varMax = MyArray(intLoop)
       End If
   Next
   MaxVal = varMax
   
End Function

HTH
Dale

> Hello everybody - Need help again.
>
[quoted text clipped - 3 lines]
>
> Thanking you in advance
 
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.