Nulls in calculated field

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

Guest

The query below is used to populate a form. It works fine except that it is
not handeling nulls approriately. I still get the ERROR# in the calculated
field Calc QTc when either fldRR or fldQT are null. I've recieved help from
Damien S on this but for some reason its still giving me the ERROR#

Any help would be greatly appreciated. Thank, Rob


SELECT tblECG.fldECGNo, tblECG.fldVisitNo, tblECG.fldTime,
tblECG.fldArrythmia, tblECG.fldRate, tblECG.fldRR, tblECG.fldPR,
tblECG.fldQRS, tblECG.fldQT,
CLng((nz([fldQT],0)/1000)/Sqr(nz([fldRR],0)/1000)*1000) AS [Calc QTc]
FROM tblECG;
 
Try IIf() instead of Nz().

I'm not clear about what is to be divided by 1000 in the end, but something
like this:

CLng(IIf(([fldRR] Is Null) Or ([fldQT] Is Null), 0,
([flgQT] / 1000) / Sqr([fldRR]/1000) * 1000)) AS [Calc QTC]
 
Thank you Allen. Works great. Have a wonderfull day.

Rob

Allen Browne said:
Try IIf() instead of Nz().

I'm not clear about what is to be divided by 1000 in the end, but something
like this:

CLng(IIf(([fldRR] Is Null) Or ([fldQT] Is Null), 0,
([flgQT] / 1000) / Sqr([fldRR]/1000) * 1000)) AS [Calc QTC]

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

RobUCSD said:
The query below is used to populate a form. It works fine except that it
is
not handeling nulls approriately. I still get the ERROR# in the calculated
field Calc QTc when either fldRR or fldQT are null. I've recieved help
from
Damien S on this but for some reason its still giving me the ERROR#

Any help would be greatly appreciated. Thank, Rob


SELECT tblECG.fldECGNo, tblECG.fldVisitNo, tblECG.fldTime,
tblECG.fldArrythmia, tblECG.fldRate, tblECG.fldRR, tblECG.fldPR,
tblECG.fldQRS, tblECG.fldQT,
CLng((nz([fldQT],0)/1000)/Sqr(nz([fldRR],0)/1000)*1000) AS [Calc QTc]
FROM tblECG;
 
Back
Top