Nested IIF's (1 Viewer)

atrium

Registered User.
Local time
Tomorrow, 08:49
Joined
May 13, 2014
Messages
348
I'm trying to create a field in my Book Mark source file to go into a merge with a set of precedent documents

If the matter is in the Magistrates court i.e. len([CourtRefNo]) is > 0 I want to use the Court Location - CourtRefNo

If the [CourtRefNo] Has nothing in it I want to check the QcatRefNo and it it has nothing in it I just want a ' '
If the QcatRefNo has something in it I want to use the QcatLoaction and the QcatRefNo

Now that's the logic, my code is below
Code:
IIF(IsNull([CourtRefNo]) Or Len([CourtRefNo]) = 0,

IIF(IsNull([QcatRefNo]) Or Len([QcatRefNo]) = 0," ",
    
"QCAT - " & [QcatLocation] & " - " & [QcatRefNo],

"Court - " & [CourtLocation] & " - " & [CourtRefNo]))

I have spread it out for clarity

Any help would be great
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:49
Joined
May 7, 2009
Messages
19,227
Swich(IsNull([CourtRefNo] + [QCatRefNo]), Null, IsNull([CourtRefNo]), "QCAT - " & [QCatLocation] & " - " & [QCatRefNo], True, "Court - " & [CourtLocation] & " - " & [CourtRefNo])
 
Last edited:

mcalex

Registered User.
Local time
Tomorrow, 06:49
Joined
Jun 18, 2009
Messages
141
To me your IIf looks like:

SQL:
IIF(
  -- condition
  IsNull([CourtRefNo]) Or Len([CourtRefNo]) = 0,
  -- truepart
  IIF(
      -- condition
      IsNull([QcatRefNo]) Or Len([QcatRefNo]) = 0,
      -- truepart
      " ",
      -- falsepart
      "QCAT - " & [QcatLocation] & " - " & [QcatRefNo],
  
      -- otherpart?
      "Court - " & [CourtLocation] & " - " & [CourtRefNo]
  )
)
I think a closing bracket is in the wrong place.

Following your rules, I think this might work, but it switches the logic around

SQL:
IIF(
  -- condition
  Not IsNull([CourtRefNo]) Or Len([CourtRefNo]) > 0,
  -- truepart
  "Court - " & [CourtLocation] & " - " & [CourtRefNo]
  -- falsepart
  IIf(
      -- condition
      IsNull([QcatRefNo]) Or Len([QcatRefNo]) = 0,
      -- truepart
      " ",
      -- false part
      "QCAT - " & [QcatLocation] & " - " & [QcatRefNo]
  )
)

hth


mcalex
 

atrium

Registered User.
Local time
Tomorrow, 08:49
Joined
May 13, 2014
Messages
348
I changed it to mcalex suggestion - still got invalid syntax

Code:
IIF(Not IsNull([CourtRefNo]) Or Len([CourtRefNo]) > 0, "Court - " & [CourtLocation] & " - " & [CourtRefNo], IIF(IsNull([QcatRefNo]) Or Len([QcatRefNo]) = 0," ", "QCAT - " [QcatLocation] & " - " & [QcatRefNo]))
 

Users who are viewing this thread

Top Bottom