Функция округления в запросе

pirat_new
Дата: 26.01.2016 16:21:07
В модуле прописал функцию для округления.
Далее ввожу в формулу в запросе и получаю ошибку: "Неверное число аргументов в выражении запроса"

IIf([kodstat]=1000 or [kodstat]=1110 or [kodstat]=1500 or [kodstat]=1501 or [kodstat]=3000,(Round97([syma]*0.036)),IIf([kodstat]=6000,(Round97([syma]*0.02)),IIf([kodstat]=1100 or [kodstat]=2500 Or [kodstat]=5000 Or [kodstat]=7200 Or [kodstat]=4000  Or [kodstat]=4500 Or [kodstat]=5500,0,Null))) AS es


Подскажите, где ошибка?
Quiet333
Дата: 26.01.2016 17:51:33
Не знаю что такое round97. А для Round надо указывать количество знаков
типа Round([syma]*0.036;2)
pirat_new
Дата: 26.01.2016 18:11:25
Quiet333,

Public Function Round97(ByVal Number As Variant, NumDigits As Long, _
Optional UseBankersRounding As Boolean = False) As Double
'Here 's the version I recently wrote that solves that last issue. I've
'sent this in to Advisor to post as an errata. I think this will work
'now... <g> -- Ken
Dim dblPower As Double
Dim varTemp As Variant
Dim intSgn As Integer

If Not IsNumeric(Number) Then
' Raise an error indicating that
' you've supplied an invalid parameter.
' Err.Raise 5
Exit Function
End If
dblPower = 10 ^ NumDigits
' Do the major calculation.
varTemp = CDec(Number) * dblPower + 0.5

' Now round to nearest even, if necessary.
If UseBankersRounding Then
' Is this a negative number, or not?
' intSgn will contain -1, 0, or 1.
intSgn = Sgn(Number)
varTemp = Abs(varTemp)
If Int(varTemp) = varTemp Then
If varTemp Mod 2 = 1 Then
' If working with a negative number,
' add 1. If working with a
' positive number, subtract one.
' That's what "- intSgn" will do.
varTemp = intSgn * (varTemp - intSgn)
End If
End If
End If
' Finish the calculation.
Round97 = Int(varTemp) / dblPower
End Function
ПЕНСИОНЕРКА
Дата: 26.01.2016 18:22:18
pirat_new,

IIf([kodstat]=1000 or [kodstat]=1110 or [kodstat]=1500 or [kodstat]=1501 or [kodstat]=3000,
(Round97([syma]*0.036)),
IIf([kodstat]=6000,(Round97([syma]*0.02)),
IIf([kodstat]=1100 or [kodstat]=2500 Or [kodstat]=5000 Or [kodstat]=7200 Or [kodstat]=4000 Or [kodstat]=4500 Or [kodstat]=5500,0,Null))) AS es

у round97 здесь 1 параметр

Public Function Round97(ByVal Number As Variant, NumDigits As Long, _
Optional UseBankersRounding As Boolean = False) As Double
 


а здесь 2 обязательных(вариант и лонг) и 1 необязательный
pirat_new
Дата: 26.01.2016 18:39:35
Спасибо!
Анатолий ( Киев )
Дата: 27.01.2016 13:44:15
pirat_new
IIf([kodstat]=1100 or [kodstat]=2500 Or [kodstat]=5000 Or [kodstat]=7200 Or [kodstat]=4000 Or [kodstat]=4500 Or [kodstat]=5500,...
Кстати, в запросе эту конструкцию можно с успехом заменить на:
IIf([kodstat] In (1100,2500,5000,7200,4000,4500,5500),...