Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculations w/ Nulls

Status
Not open for further replies.

mdr227

Programmer
Nov 17, 2000
114
US
I am doing some calculations on an ASP page using a query in access that sums up certain columns. For some selections there is no data to sum up so the returning value is null or empty. The problem is I cannot get this to add with other values because it is non-numeric.

For example, I have the query qryTotals with the field 'total'.

If I try to set a variable varTotal = rs1("total") and rs1("total") is null or = "" then my next calculations don't work.

So..... I try and set the variable = 0 when rs1("total") = "" or rs1("total") is null

if rs1("total") = "" then varTotal = 0 end if
or
if rs1("total") = null then varTotal = 0 end if

However.... this does not work. The if then statement is never evaluated as being true for some reason.

Can someone tell me what I am doing wrong?

Thank you.
 
Try this:

if rs1("total")="" OR isnull(rs1("total")) Then
varTotal=0
End if

-VJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top