IIF(ISNULL(...),NULL,...) fires: invalid use of null (?????)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know whay this:

Select Case RST.Fields(i).Name
Case "data", "startdate", "endDate"
RST.Fields(i) =
IIf(IsNull(Forms(ff.Name).Section(acDetail).Controls(RST.Fields(i).Name).Value),
Null,
ConvertiDataISO(Forms(ff.Name).Section(acDetail).Controls(RST.Fields(i).Name).Value))
Case Else
.....
End Select

will always fire an error: invalide use of null on the field enddate, which
can really happen to be NULL

while this:

Select Case RST.Fields(i).Name
Case "data", "startdate", "endDate"

If
IsNull(Forms(ff.Name).Section(acDetail).Controls(RST.Fields(i).Name).Value)
Then
RST.Fields(i).Value = Null
Else
RST.Fields(i).Value =
ConvertiDataISO(Forms(ff.Name).Section(acDetail).Controls(RST.Fields(i).Name).Value)
End If

Case Else
.....
End Select

works just fine? Didn't both do the same thing?

The table field "enddate" can accept Null values.
I tried importing everything in a new database thinking of some kind of
corruption. But didn't fix it...

There should be something with the IIF function, I guess.

Thanks,
Rocco
 
I believe that IIF only works in queries, and it looks like you are using it
in VBA, so you need the second syntax in order to work in VBA.

Please let me know if I can provide more assistance.
 
There should be something with the IIF function, I guess.

RTFM

IIf() is a function, therefore all its parameters are evaluated before the
results are passed to it. If one of those evaluations fails, then so does
the whole call.

Hope that helps


Tim F
 
Back
Top