A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Minimum Value of three fields



 
 
Thread Tools Display Modes
  #1  
Old July 8th, 2004, 02:28 PM
Denise
external usenet poster
 
Posts: n/a
Default Minimum Value of three fields

I am trying to get the minimum value of three fields and
cannot get it to work like excel. In the query, I tried
using FieldName: Min([Field1]+[Field2]+[Field3].

Does anyone know how to do this in Access?

Thank you.
  #2  
Old July 8th, 2004, 04:04 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default Minimum Value of three fields

"Denise" wrote in message
...
I am trying to get the minimum value of three fields and
cannot get it to work like excel. In the query, I tried
using FieldName: Min([Field1]+[Field2]+[Field3].

Does anyone know how to do this in Access?


Aggregate functions in Access (Sum, Min, etc.) work across rows, not
columns or a set of supplied values.

Try...

IIf([Field1][Field2], IIf([Field1][Field3], [Field1], [Field3]),
IIf([Field2][Field3], [Field2], [Field3]))


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


  #3  
Old July 9th, 2004, 03:15 AM
Dale Fye
external usenet poster
 
Posts: n/a
Default Minimum Value of three fields

Denise,

I use a function I created to do this type of thing. Create a code module
and paste the following code into it. You can then use this function in
your query something like:

MinValue: Minimum([Field1], [Field2], [Field3])

The nice thing about this function is that you can use it to compare any
type of field data, so if you want to compare dates, pass it dates, if you
want to compare text, pass it text. The other advantage is that you can
pass it as many values as you want, since it uses a parameter array.

Public Function Minimum(Paramarray varArray()) as variant

Dim intLoop as Integer
Minimum = NULL
For intLoop = LBOUND(varArray) to UBOUND(varArray)
if ISNULL(Minimum) OR varArray(intLoop) Minimum then
Minimum = varArray(intLoop)
endif
next intLoop

end Function

HTH
Dale

"Denise" wrote in message
...
I am trying to get the minimum value of three fields and
cannot get it to work like excel. In the query, I tried
using FieldName: Min([Field1]+[Field2]+[Field3].

Does anyone know how to do this in Access?

Thank you.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import to custom fields in contacts jdh General Discussion 1 July 2nd, 2004 07:08 PM
How to store calculated fields ? Nico Using Forms 13 June 7th, 2004 02:57 PM
Lost text fields in merge CGiannini General Discussion 5 June 4th, 2004 10:23 PM
Lookup fields on label report Howard Setting Up & Running Reports 1 June 3rd, 2004 02:43 AM
Mail Merge two fields that have multiple lines with new line control code Eric Li Mailmerge 7 May 25th, 2004 06:10 PM


All times are GMT +1. The time now is 07:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.