Handling Null in DSum

A

Anthony Viscomi

What can I place in the following statement in order to make provisions for
Null?

Dim TotalDueX As Integer
TotalDueX = DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'")

Thanks!
Anthony
 
C

CJR

Anthony

Dim TotalDueX As Integer
Dim iTemp as variant
iTemp= DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'")
TotalDueX =iif(isnull(iTemp),0,iTemp)

The last line substitutes the value 0 if iTemp IS NULL (replace the 0 with
the desired default value)

Hope this helps

Chris
 
A

Anthony Viscomi

Great! Thanks
CJR said:
Anthony

Dim TotalDueX As Integer
Dim iTemp as variant
iTemp= DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'")
TotalDueX =iif(isnull(iTemp),0,iTemp)

The last line substitutes the value 0 if iTemp IS NULL (replace the 0 with
the desired default value)

Hope this helps

Chris


Anthony Viscomi said:
What can I place in the following statement in order to make provisions
for Null?

Dim TotalDueX As Integer
TotalDueX = DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'")

Thanks!
Anthony
 
S

Steve Schapel

Anthony,

TotalDueX = Nz(DSum("[Cost]", "[dbo_course]", "[SS] = '" & Me!SS & "'"),0)
 
Top