|
Question : Iff or CASE Statement
|
|
Here is my problem,
I have 3 fields name Field4 Field5 and Filed16
Contents of Fields would be,
Field4 Field5 Field16 70 90 W 96 45 W 40 50 N 60 30 N 20 20 N
What i need is to do some kind of iif statement within a query where in my english version i get this
When field 16 = W the largest of Field4 & Field5 gets populated into say SizeAcross: and the smallest into to Say SizeDown:
And also
When Field16 = N the smallest of Field4 & Field5 gets populated into say SizeAcross: and the largest into SizeDown:
and finally if Field16 = W or N and Field4 = Filed5 then no change.
I have trying to get this to work on my data which has some correct entries and quite a few incorrect entries, Any help on this would be great.
It may not be an IIF or CASE statement but those are the ones I am assuming which will resolve this little problem.
Thanks Psyclones
|
|
Answer : Iff or CASE Statement
|
|
Hi Psyclones,
You need a function to do this for you. The one below will do it.
In your query you have something like:
SizeAcross:GetVal(Field4,Field5,Field6,"SA")
SizeDown:GetVal(Field4,Field5,Field6,"SD")
Pete
Function GetVal(f4, f5, f6, SAorSD) Dim largest Dim smallest If f4 > f5 Then largest = f4 smallest = f5 Else largest = f5 smallest = f4 End If If SAorSD = "SA" Then If f6 = "N" Then GetVal = smallest Else GetVal = largest End If Else If f6 = "N" Then GetVal = largest Else GetVal = smallest End If End If End Function
|
|
|
|