Nulls in calculated field

R

RobUCSD

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;
 
A

Allen Browne

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]
 
R

RobUCSD

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top