Novice,
Part of your problem may be that Type is a reserved word in Access.
Whenever you use reserved words a field names (this is highly frowned upon)
you need to wrap them in brackets [], otherwise, you may confuse Access and
get error messages or unexpected results. I would change the field name if
you can.
I've got a function that I use that may simplify this some. the function
fnMax( ) accepts an array of values and will determine the maximum value
from the set of values passed to it. I leave it to you to modify this to
get the fnMin function. Because you don't want your MgmtFee1 to be less
than a particular value ($25 if Type is 10, $75 if Type is anything else),
you would use this function like:
MgmtFee1: IIF([Customer].[Type] = 10, fnMax(25, [MgmtFee]), fnMax(75,
[MgmtFee]))
If Type =10 and [MgmtFee] = 30, then MgmtFee1 will be 30
If Type =10 and [MgmtFee] = 20, then MgmtFee1 will be 25
If Type <>10 and [MgmtFee] = 30, then MgmtFee1 will be 75
If Type <>10 and [MgmtFee] = 120, then MgmtFee1 will be 120
Public Function fnMax(ParamArray SomeValues() As Variant) As Variant
'Accepts an array of parameters, preferably of the same data type, but
can be any type including NULL values
'fnMax(3, 7, 10) = 10
'fnMax(#9/1/07#, #9/15/07#, #10/1/06#) = #9/15/07#
Dim intLoop As Integer
Dim myMin As Variant
For intLoop = LBound(SomeValues) To UBound(SomeValues)
If IsNull(SomeValues(intLoop)) Then
'do nothing
ElseIf IsEmpty(myMin) Or SomeValues(intLoop) < myMin Then
myMin = SomeValues(intLoop)
End If
Next
fnMin = myMin
End Function
HTH
Dale
Novice2000 said:
Hi,
I am trying to set minimum fees in a query from which I print a report.
The
management fee for a type"10" customer cannot be lower than $25. The
management fee for all other types (1,2,3,4,5,6,7,8,9 etc) cannot be lower
than $75.
MgmtFee1:
IIf([Customer!Type]="10",IIf([MgmtFee]<=25,25,[MgmtFee]),IIf([MgmtFee]<=75,75,[MgmtFee]))
This expression isn't working. What am I doing wrong? Thanks