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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |