Désolé mais je ne saisi pas bien ton besoin.
Tu peux utiliser des requêtes pour faire ce genre de caclul et tu disposes de diverses fonctions (l'équivalant de SI() est IIF()). Si ta logique est vraiment complexe, cela peut devenir rapidement illisible, une astuce consiste à utiliser une fonction VBA à la place, voici un exemple :
=iif(iif(isnull(A); 0; A)=1 and iif(isnull(B); 0; B)=2; iif(iif(insull(C); 0; C)=3 and iif(isnull(D); 0; D)=4;"Texte1";"Texte2");"Text3")
peut être remplacé par
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| public function CalculerCondition(prmChampA as variant, prmChampB as variant, prmChampC as variant, prmChampD as variant) as string
'l'utilisation de type variant permet de gérer les nulls
dim result as string
dim a as long
dim b as long
dim c as long
dim d as long
if isnull(prmChampA) then
a=0
else
a=prmChampA
end if
if isnull(prmChampB) then
b=0
else
b=prmChampB
end if
if isnull(prmChampC) then
c=0
else
c=prmChampC
end if
if isnull(prmChampD) then
d=0
else
d=prmChampD
end if
if a=1 and b=2 then
if c=3 and d=4 then
result="Texte1"
else
result="Texte2"
end if
else
result="Text3"
end if
CalculerCondition=result
end function |
dans ta requête tu mets
=CalculerChamp(A, B, C, D)
Partager