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)
 

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

Similar Threads

DSum 3
Assinging a value to a txtBox 6
Problem w/referencing a Sub-Form via VBA 1
Invalid Use Of Null 2
Work Budget Salary vs Real Time Salary 0
DSUM Date Criteria 3
Problem with DSum 5
dlook finding NULL 2

Top